Pushes provided string onto end of self : String class Extension « String « Ruby
- Ruby
- String
- String class Extension
Pushes provided string onto end of self
class String
def push_word(other)
newself = self + other.to_s
self.replace(newself)
end
end
a = "this is a test"
puts a.push_word "another"
Related examples in the same category