From: Skave Rat Date: 2008-08-01T21:25:48+09:00 Subject: Re: problem with "starts_with?" matt neuburg wrote: > Skave Rat wrote: > >> How can I get this code to work in my classes? >> http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/ >> StartsEndsWith.html > > require 'rubygems' > require 'activesupport' > include ActiveSupport::CoreExtensions::String > > puts "howdy".starts_with?("ho") > > Is that the kind of thing you mean? m. hm, yea, but the problem is it's not rails but simple ruby. So I'd just like to add def starts_with?(prefix) prefix = prefix.to_s self[0, prefix.length] == prefix end to my code where I can use it on all strings inside. -- Posted via http://www.ruby-forum.com/.