3 ms·
Ruby can use both "{...}" and "do ... end", with a slight difference between the two (precedence): def some_method { ... } def some_method; ... end
by clyfe 16y ago
Ruby can use both "{...}" and "do ... end", with a slight difference between the two (precedence):
def some_method { ... }
def some_method; ... end
obj.something # "something" is allways a method
# never a var, say accessor (getter, setter &c ...)
- steveklabnik 16y agodef cannot have {}, it needs ;/end. {} or do/end work for blocks, however.
- clyfe 16y agoindeed, you are right
- axod 16y agoHaving optional beauty isn't really any beauty at all though. I'm just more at home with exact, specific concise well structured syntax. I know it's an extremely unpopular opinion to hold, especially round these parts, but I don't see any beauty in Ruby syntax. Same with Python...