Ruby method call with a symbol parameter with no space -
i saw in rails app reviewing expected error, working. confused way method being called parameter. no spaces, 2 words separated 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 string:
ree-1.8.7-2012.02 :004 > muffin'd' "d"
is expected , correct thing?
ruby enjoys 1 of relaxed grammars in industry. yes, space optional. , try muffin(:tuffin)
if want colleagues see what's going on.
furtherless, can write:
def muffin x
yet example of "because can" isn't valid reason doing something. c-;
Comments
Post a Comment