[rspec-devel] [Proposed Refactoring] - Current ExampleSpace class subclasses Test::Unit::TestCase

Jay Levitt lists-rspec at shopwatch.org
Wed Aug 22 19:44:31 EDT 2007


On 8/22/2007 6:06 PM, Scott Taylor wrote:
>>>> It's more like the ! ruby methods. It's dangerous, there is a non
>>>> dangerous alternative and you should know precisely what you're  
>>>> doing.
>>>> (perhaps we should rename it before! to follow that convention).
>>> I always thought that that was a LISP/Scheme convention - the
>>> question mark signifying a boolean return value, and the exclamation
>>> point signifying an "unsafe" function - unsafe in the Haskell/
>>> functional way of thinking (i.e. change the state of an object).
>>> Obviously Ruby isn't a functional language, so I've always been a
>>> little bit curious as to what is considered "dangerous".
>> I don't think of ! as dangerous. To me it means "do this to yourself."
>> When you say list.reject { ... } you get a new list back with the
>> appropriate items removed. When you say list.reject! { ... }, those
>> items are actually removed from the list you're sending the message
>> to. Make sense?
> 
> So I guess you do understand it as "dangerous" - that is, in the  
> functional sense - of modifying the data your working on.  But this  
> would make most methods in ruby ! methods.

David A. Black posted a great blog entry about this last week:

http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist

Jay



More information about the rspec-devel mailing list