The following code has the collector variable "sql" starting off life as a string but then coerced into fixnum. There is no apparent reason for such a conversion.
segs=['segment1', 'segment2']
sx=1
sqlout = segs.inject("select ") do | sql, seg|
puts "class of sql: #{sql.class}"
salias = "#{seg.slice(1,3)}"
if sx > 1 then sql <<= " ," end # this if the offending line 8
sql <<= "#{salias}.score as #{seg}_score"
puts "class of sql at end: #{sql.class}"
sx+=1
end
The results are
class of sql: String
class of sql at end: String
class of sql: Fixnum
TypeError: can't convert String into Integer
<< at org/jruby/RubyBignum.java:751
<< at org/jruby/RubyFixnum.java:1155
(root) at ./pivot.rb:8
each at org/jruby/RubyArray.java:1613
inject at org/jruby/RubyEnumerable.java:820
(root) at ./pivot.rb:5