You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
l[1] looks like addressing an array index instead of calling a method, therefore it does not do what I would expect from reading the code. ´l.(1) looks like a method call where the method name is missing. When I saw it for the first time, it was hard to understand it. This way of calling a proc is just mentioned as syntactic sugar in two method documentations, so if you are not familiar with this construct, it is most likely just confusing and thereby impacts readability. l.call(1) is pretty easy to understand. Although it uses more characters than the other two examples, I prefer to have easily readable code.
The text was updated successfully, but these errors were encountered:
There are three different ways to call a proc or lambda:
According to http://www.ruby-doc.org/core-2.0/Proc.html , they all seem to be equivalent.
l[1]
looks like addressing an array index instead of calling a method, therefore it does not do what I would expect from reading the code.´l.(1)
looks like a method call where the method name is missing. When I saw it for the first time, it was hard to understand it. This way of calling a proc is just mentioned as syntactic sugar in two method documentations, so if you are not familiar with this construct, it is most likely just confusing and thereby impacts readability.l.call(1)
is pretty easy to understand. Although it uses more characters than the other two examples, I prefer to have easily readable code.The text was updated successfully, but these errors were encountered: