Tim Hoolihan

Technical Blog

Skip to content
  • Home
  • About
  • Contact Me
  • Sites
  • Slides

Simple String Extension in Ruby

Based on a blog post from Steve Yegge…

#ruby
class String
   def endswith(arg)
     (self =~ /.*#{arg}$/) != nil
   end
end

#to test
irb>"extension".endswith("ion")
This entry was posted in Programming, Ruby and tagged class extensions, linkedin, Ruby on 2009.02.18 by Tim.

Post navigation

← Flatland Won the ’09 Shootout →

Pages

  • About
  • Contact Me
  • Sites
  • Slides

Categories

Archives

Proudly powered by WordPress