In fiddling with ruby, I noticed that the method names can be really interesting – rails (maybe others too, dunno) has some methods that look like:
which is typically used to return a boolean indicating wether or not “stop” is true. Ok, cool. Another interesting method call is
which appears to be identical to
. That part really confused me, and I’m still not sure I have it completely clear.
are two very different things. The first is a reference to the instance method close – which you can pass around. The second is a specific invocation to the instance method. In ruby the parentheses appear to be optional if there are no arguments getting passed in to the function.
Dave Slorah pointed out that the parantheses option thing extends beyond just the no-argument methods – it applies all over the place!
irb(main):010:0> def foo(bar,baz) irb(main):011:1> puts bar irb(main):012:1> puts baz irb(main):013:1> end => nil irb(main):014:0> foo "hello", "world" hello world
My first thought it “Wow – that’s almost Objective-C like…”