|
|
|
|
|
by _dain_
1641 days ago
|
|
>Rails prides itself on being able to write `5.minutes` - they monkey patch numbers to add a minutes function. In languages like Nim with Uniform Function Call Syntax this is actually completely natural and universal: f(a, b) and a.f(b) are completely equivalent in all cases. So if you have an ordinary `minutes` function that takes a number and returns a time/duration, you can write either 5.minutes or minutes(5) as the fancy takes you. No special monkeypatching required, it just works everywhere for every function and every type. |
|