Of course there are a thousand ways to get this done, but is the simplest (or most elegant) way to achieve this?
[4,8].max
That's actually not too shabby, but what would you do?
It's a general comparison operator. It returns either a -1, 0, or +1 depending on whether its receiver is less than, equal to, or greater than its argument.
The use of :: on the class name means that it is an absolute, top-level class; it will use the top-level class even if there is also a TwelveDaysSong class defined in whatever the current module is.
If you don't want to spawn an array, there's the conditional operator:
max = a > b ? a : b
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With