Following a discussion with a friend about operator overloading. I am looking at creative and/or useful example usage of operator overloading in Scala. I have some cool illustrations:
- Mathematical constructs, like linear algebra or complex numbers (
+ * -) - Mimicking shell pipe and redirections (
| > < >>) - Alternative expressions in Grammars (
|)
Have you other nice examples ?
The ones I don’t mind using occasionally:
|>(e.g.,someValue |> println):=one some structures like observable value holders to mimic assignment<=>(two-way),<==(one-way) (e.g.,field.enabled <=> options.isEditable