I was looking through some Rails source code and came across
# File vendor/rails/activesupport/lib/active_support/vendor/builder-2.1.2/builder/css.rb, line 129
129: def target!
130: @target * ''
131: end
What does the * ” do? Is that multiplication by an empty string…? And why would you do that.
This is a bizarre syntax. These are equivalent:
so in this case it joins all the entries of
@targetinto one string, with nothing between the entries.Note: if you do something like
[1, 2, 3] * 3(using anintinstead of astr), you’ll get three concatenated copies of the array instead.