On Thu, Feb 14, 2013 at 1:06 PM, Joel Pearson <[email protected]> wrote:
> I've been wondering about the best way to quickly create a "bang"
> version of a method (specifically one which overwrites self). Is there a
> better DRY approach than the below?
> I guess that there's probably a way to input a list of methods as
> symbols and output bang versions of each as new methods, but at the
> moment I'm more interested in the wording of the bang method itself.
>
> This is the best I can come up with (in pseudo-code):
>
> def test( arg1, arg2, arg3=true )
>   #Do stuff with the args that returns a value
> end
>
> def test!(*p)
>   replace test(*p)
> end
>
> --
> Posted via http://www.ruby-forum.com/.
>

Hi...

IMHO sometimes this is useful:

def foo(something)
  dup.foo!(something)
end

def foo!(something)
  # do the work...
end

e.

-- 
[email protected] | 
https://groups.google.com/d/forum/ruby-talk-google?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"ruby-talk-google" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to