M
MonkeeSage
Hi --
I'm not sure I follow, so this may not be relevant, but in-place
changes (changes to the receiver) are one form of "danger", in this
sense. They're just not the only form.
Don't mind me, I'm just over-analyzing. ;P After remaking that
"danger" can be ambiguous above, I posted a characterization of !
where I tried to disambiguate "danger" in the following way: "Causes
some side-effect that is incompatible or sufficiently different from
the non-bang version". Since everything is "dangerous" in ruby from
the perspective of a haskeller, I thought it might be helpful to
differentiate between mutation of the receiver (not generally
considered dangerous in ruby), and incompatible/unexpected behavior as
compared to the non-bang version. Most bang-methods, I think, do both.
I don't know of any that don't come in pairs, where the ! one
indicates "danger" (reverse/reverse!, exit/exit!, etc.).
I agree. That was one of my reasons for not supporting "push!" --
along with the fact that the method name is fully descriptive, and
that a ! suffix would be confusing, it would be unbalanced (q.v.,
previous post).
Good question. I see this in ri but I don't see it actually on any
objects. I'm not sure what it is.
It appears to be an alias of an alias (power! -> ** -> rpower).
Bignum#rpower returns a new Rational, so, indeed, the operation is non-
dangerous and does not mutate the receiver...I guess matz just had an
extra "!" lying around and didn't want to waste it, heh.
David
Regards,
Jordan