4 ms·
Yeah, #succ is something else. For example, if your object supports #succ then you can use it in ranges. e.g., (1..10), but also ("apple".."kiwis") or ('A'..'
by jfarmer 15y ago
Yeah, #succ is something else. For example, if your object supports #succ then you can use it in ranges.
e.g., (1..10), but also ("apple".."kiwis") or ('A'..'Z').
In this case, String#succ returns a string with the last alphanumeric character transformed into its successor, e.g., "apple".succ == "applef".
The only time I've used it is implementing the range interface; I've never called it directly, let alone to increment an integer.
- neutronicus 15y agoI assume you mean "apple".succ == "applf" ?
- jfarmer 15y agoYes