From: Jean-Hugues ROBERT Date: 2002-04-02T02:40:13+09:00 Subject: Re: String#begins?(s) Hi, I agree that str.begins?( xxx) is not ideal (try saying it aloud). "begin_with?" is certainly better. I tend to prefer "start_with?" however. But xx1.AAA( yy2) is sometimes easier to name yy2.BBB( xx1). So... substr.begin?( str) could make sense (I still prefer "start?") if foo.start? "hello, world!" then # "hello, world!" begins with foo end Hence, I vote (for what's it worth) for: s.start?(x) Returns true if substring s is at the beginning of string x. s.end?(x) Returns true if substring s is a the end of string x. s.include?(x) Returns true if s includes substring x However this may be counter intuitive because we are used to have str.MMM( substr) signatures, versus substr.MMM( str). jhr if paramount_logo.start? the_movie then movie_producer = 'Paramount' elsif lucas_films_logo.start? the_movie then movie_producer = 'Lucas films' else movie_producer = 'Independant' end vs if the_movie.start_with? paramount_logo then movie_producer = 'Paramount' elsif the_movie.start_with? lucas_films_logo then movie_producer = 'Lucas films' else movie_producer = 'Independant' end At 12:31 01/04/2002 +0900, you wrote: >Hi, > >In message "String#begins?(s)" > on 02/04/01, Tim Sutherland writes: > >|class String >| def begins?(s) >| self[0...(s.size)] == s >| end >|end >| >|Worthwhile? > >I don't like the name "begins?". It's not obvious. >I don't like names like "beginWith?" or "begin_with?" neither. > > matz. >p.s. >If you can find a good name, you've accomplished 90% of the job. --------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17 _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com