3 ms·
Sort isn't a great example because its presumably only looking at public fields of the elements only and could be functional. However, Arrays in ruby grow so t
by jayd16 6y ago
Sort isn't a great example because its presumably only looking at public fields of the elements only and could be functional. However, Arrays in ruby grow so they presumably have private fields and manage their own internal state. This is what the parent was referring to.
- shados 6y agoYou can do that with various constructs without doing OOP style though. Eg: in JS you could use a symbol to store that state that is only known to the methods allowed to handle he array "internal" state. (JS isn't a great example because there are ways to get access to those hidden symbols when you shouldn't, but it doesn't have to be that way)