Railstic

sharing experiences

Tidbit: Converting Strings with Line Feed to Array

| Comments

If you have trouble when converting string to array, check if your string includes any line feed (\n). Check how Array("string") behaves:

irb(main):001:0> Array("izzet emre \nkutlu")
=> ["izzet emre \n", "kutlu"]

This output is not what most of the people expected. Be careful!

Comments