[YANQ] - how to create/modify []=

Hi sir David (aka dblack@candle.superlink.net):

You enlightened awhile ago:

You may or may not know it in advance:

arr[0] =3D gets

Also, what you’re describing is how assignments work: the return value
of the assignment is the right hand side of the expression. True, =3D
isn’t an assignment, but a method call… But the cool thing about
the =3D syntax is that it looks and acts just like an assignment.

So, for example, you can do:

a =3D b =3D arr[0] =3D x

which would probably blow up if =3D no longer did what it looks like
it does (i.e., act like an assignment).

I overlook this. Yes, it does look like an assignment. Thanks, sir David.

Or, to put it another way: if a method that altered an array element
were going to return the array itself, then there would be much better
things to call it than =3D .

I’ll take a look at replace or insert. My bad :frowning:

If you change Array#=3D globally, then the main repercussions are that
you can’t safely use any libraries (including core ones), and no one
else can use any libraries or modules you write. So it’s probably not
a great idea :slight_smile: If you do one of the non-global things, like putting
the change in a module and extending individual objects, then it’s
safer and somewhat more sociable.

My bad. I cannot see big picture… I’ll try creating/extending one… I
hope it is not difficult…

David

Many thanks, sir David.
’ very informative and enlightening.

Kind regards,
-botp

If you change Array#=3D globally, then the main repercussions are that
you can’t safely use any libraries (including core ones), and no one
else can use any libraries or modules you write. So it’s probably not
a great idea :slight_smile: If you do one of the non-global things, like putting
the change in a module and extending individual objects, then it’s
safer and somewhat more sociable.

My bad. I cannot see big picture… I’ll try creating/extending one… I
hope it is not difficult…

Hirofumi’s post already does this - it’s the best solution so far.

Gavin

···

From: “Peña, Botp” botp@delmonte-phil.com