2012/2/3 Peter Vandenabeele <peter / vandenabeele.com>: > <alternative> > def get_words > [].tap do |a| > while !(input = gets.chomp).empty? > a << input > end > end > end Aw. Do not abuse #tap, please. It's extremely unreadable, especially to a beginner. > * Use [].tap{|a| a<< stuff} so you do not have to return the > result array explicitly (I am not having a variable "words" > or "array" in the function, it is returned as the final result but > not stored in an explicit local variable; so I can impossibly > forget to return the built up array at the end, because "tap" > returns it automatically There is no advantage to using constructs with tap over regular variable I know of. IMO #tap should only be used to "inject" debugging or other side-effects into a long method chain. (Although, if you have a method chain so long, you probably have other problems...) -- Matma Rex