How can I 'join' an array adding to the beginning of the resulting string the first character to join?

前端 未结 6 1126
感动是毒
感动是毒 2021-01-21 06:11

I am using Ruby on Rails 3 and I am trying join an array with the & character. I read the Ruby documentation about that.

My array is:

6条回答
  •  半阙折子戏
    2021-01-21 06:50

    A slightly modified form of the answer you provided may be less computationally intensive, given the size of your array.

    (['']+Array.wrap(classes)).join('&')
    

    This works for whether classes is a type Array

提交回复
热议问题