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