×
The Ruby and Rails community linklog
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!
Comments
Hi Mehdi,
I don’t know if you are running rubycademy (there’s no way for visitors to get that info) but this particular card is misleading to me. Here are my comments on the card code (can’t comment directly on rubycademy):
The code with the block-reference is marked “better” because it’s a one-liner (I guess), but this example is contrived because it does nothing except delegate to #each. (So a even more “better” way would be to use
aliasoralias_method)In the real world there may be code either before
#each, certainly inside the block (before passing to the&block).BTW, it is generally better to use
yield + block_given?because there’s no&blockparameter to make available in the current closure.Best Regards
Post a comment