J
Joe Peterson
Hi all,
I am relatively new to Ruby, and I am loving it! I have a long Python
background, and one of the things I love about Ruby is that it is easier
to know and even remember which methods are destructive and which just
return a result.
Looking through the "String" class methods, one sticks out: "insert".
Almost all others (and all that might be ambiguous), like "delete",
"sub", etc., have both the non-destructive and destructive versions
("delete", "delete!", etc.).
Does anyone know the reason "insert" isn't this way? It seems so
similar to delete that I would have expected it not to change the string
unless a "!" were at the end, but it looks like there is just the
non-"!" one, and it does change the string...
Thanks, LavaJoe
I am relatively new to Ruby, and I am loving it! I have a long Python
background, and one of the things I love about Ruby is that it is easier
to know and even remember which methods are destructive and which just
return a result.
Looking through the "String" class methods, one sticks out: "insert".
Almost all others (and all that might be ambiguous), like "delete",
"sub", etc., have both the non-destructive and destructive versions
("delete", "delete!", etc.).
Does anyone know the reason "insert" isn't this way? It seems so
similar to delete that I would have expected it not to change the string
unless a "!" were at the end, but it looks like there is just the
non-"!" one, and it does change the string...
Thanks, LavaJoe