L
lalawawa
I want to write a method within class Array that will put single
quotes around every element of the array.
"this" doesn't work in Ruby. If it did I would write
class Array
def quote
length.times {|i| this = "'" + this.to_s + "'"
end
end
Ruby doesn't know what I mean when I say "this". How do I call the []
operator when I'm in the array class and have the language realize I'm
not building a list?
quotes around every element of the array.
"this" doesn't work in Ruby. If it did I would write
class Array
def quote
length.times {|i| this = "'" + this.to_s + "'"
end
end
Ruby doesn't know what I mean when I say "this". How do I call the []
operator when I'm in the array class and have the language realize I'm
not building a list?