Unfortunately, like many other programming languages ββon the planet, Ruby does not allow literal overloading. If you need literal overload, you will have to use one of the few programming languages ββthat support it, such as Ioke or Seph .
Here is an example in Ioke:
[] = method(foo, foo println) [1] ; 1
And in Seph:
[] = #(foo, foo println) [1] ; 1
[Note that this, of course, will lead to the chaos of your system, since, for example, most of the standard Ioke / Seph library is implemented in Ioke / Seph, and they use lists everywhere, so on a production system, you will want to encapsulate this correctly.]
source share