4 ms·
something() { } obviously is a definition, something() is obviously a call. Why is that hard for you?
by iphorde 6y ago
something() { } obviously is a definition, something() is obviously a call.
Why is that hard for you?
- steveklabnik 6y agoThat is actual Ruby syntax for an invocation of something, so it may or may not be obvious depending on what you're used to. (Though most Rubyists would drop the ()s) Also, as mentioned, in many languages it is valid syntax for an invocation of something, followed by a new scope.
- Groxx 6y agoor is it obviously executing `something()` followed by an anonymous scope with a less-common indentation pattern, e.g. equivalent to var x = 1; something(); { var x = 2; } // x is now 1 again, as the scope // containing the new variable x=2 is gone something(); or, as mentioned in another comment, is it passing an execution block to `something()`? (I didn't mention that in my original since it's a bit less common of a language feature, but it's valid too) enforced semicolons and/or significant whitespace/newlines can resolve this in some cases, but it of course depends on the language. and diverging too far from common langs has its own downsides too, especially where you're changing the interpretation of what are already common patterns.