Platinum Partner

Ruby Array Extension Method To Return Array Elements As Quoted Strings

// Ruby Array extension method to return array elements as quoted strings


class Array
  def to_quoted_s(q="'")
    "#{q}#{self.join("#{q}, #{q}")}#{q}"
  end
end


Example:

a = ['a', 'b', 'c', 'd', 'e']
puts a.to_s # abcde
puts a.to_quoted_s # 'a', 'b', 'c', 'd', 'e'
puts a.to_quoted_s("\"") # "a", "b", "c", "d", "e"

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}