3 ms·
#prepend replaces in place? There's no #prepend! ?
by getsat 15y ago
#prepend replaces in place? There's no #prepend! ?
- yxhuvud 15y agoThat would be redundant, since there would be no difference from String#+.
- petercooper 15y agoNo. Conventionally, "bang" methods should only be created as 'dangerous' versions of non-bang methods. There was no non-bang method to make a 'dangerous' version of in this case so it's non-bang by default. This is a commonly misunderstood naming convention in Ruby (and I dare say I don't even understand all the intricacies!) There are quite a few examples of this in Ruby. For example, Array#keep_if which changes an array in place.
- getsat 15y agoI guess I misunderstood your definition of "in place". That jives with what I've understood about Ruby so far.