From: dblack@... Date: 2006-10-06T04:33:55+09:00 Subject: Re: question mark at end of method name Hi -- On Fri, 6 Oct 2006, Paul Lutus wrote: > py wrote: > >> what does the question mark at the end of a method name represent? >> >> for example: >> >> x = "something" >> break if x.empty? >> >> i've seen what ! does....what is ? > > .empty? means "is it empty?". It tries to suggest that a question is being > asked. It's unfortunate that the "!" syntax, which seems similar, actually > means "apply the result to the present object." Actually the ! at the end of a method name means, according to Matz, that it's a "dangerous" method; and such methods always (in the core at least) exist in a pair with a non-!, non-dangerous method of the same name. "Danger" in this context can mean receiver-changing, and often does mean that, but it doesn't have to. David -- David A. Black | dblack@wobblini.net Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org