I saw something in a Rails app I am reviewing that I expected to be an error, however it is working. I am confused by the way this method is being called with this parameter. No spaces, just two words separated by a colon:
ree-1.8.7-2012.02 :001 > def muffin(x)
ree-1.8.7-2012.02 :002?> puts x.inspect
ree-1.8.7-2012.02 :003?> end
=> nil
ree-1.8.7-2012.02 :004 > muffin:tuffin
:tuffin
Also works with a string:
ree-1.8.7-2012.02 :004 > muffin'd'
"d"
Is this the expected and correct thing?
Ruby enjoys one of the most relaxed grammars in the industry. Yes, the space is optional. And try muffin(:tuffin)
if you want your colleagues to see what's going on.
Furtherless, you can write:
def muffin x
Yet another example of "because I can" isn't a valid reason for doing something. C-;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With