|
|
|
|
|
by whstl
1000 days ago
|
|
A different pattern I like in Ruby is the assignment with begin...end: fred = begin
user_finder = ...
user_finder.find('fred')
end
Again, not always "self-documenting" as whipping out a new function, but useful if you need to separate chunks and keep the code linear.The only issue with Ruby itself is that the scope is not lexical, so you can still use `user_finder` outside the block above (linters can catch it, though). But it's still worth to separate code without having a brand new method. |
|