Why frozen string literals?

@MSP_Greg, is there any difference with the magic comment between how Ruby treats single and double quoted string literals ?


Well if I can’t do …

puts 'Value is: '<<value.inspect

… then (IMO) interpolation …

puts "Value is: #{value.inspect}"

… is better than …

puts 'Value is: %s' % value.inspect

… and even …

puts 'Value is: ' + value.inspect

and always better than this …

puts String.new('Value is: ')<<value.inspect
1 Like