--000e0ce03d926bcce604b03488cd
Content-Type: text/plain; charset=ISO-8859-1

On Wed, Oct 26, 2011 at 9:04 AM, Marc Heiler <shevegen / linuxmail.org> wrote:

> Given is a small .rb file.
>
> In that .rb file, class Array is modified and a convenience
> method is added.
>
> class Array
>
>  def rand
>
> I want to limit this modification to only that specific
> .rb file though.
>
> When I use that .rb file in a larger project, I do not want
> the modification of class Array to leak out into other .rb
> files. Is there a way to limit the scope of the modification?
>
> Of course I can define a method simply and call that, but:
>
>  array.rand
>
> Looks better to my eyes than:
>
>  rand(array)
>
> So I would prefer to be able to do only the array.rand.
>
> --
> Posted via http://www.ruby-forum.com/.
>
>
Things like that will be available in Ruby 2.0, but aren't available yet (
http://yehudakatz.com/2010/11/30/ruby-2-0-refinements-in-practice/)

--000e0ce03d926bcce604b03488cd--