Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



I assume you mean "apple".succ == "applf" ?


Yes




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: