2

Wondering if solidity supports operator overloading like python does?

Something like:

---WARNING PSEUDOCODE---

overload __+__ {
    if (type(arg1) == string && type(arg2) == string){
        return arg1.append(arg2);
    }
}

I would use this to rewrite the SafeMath library, as SafeMath adding/multiplying/etc. in a long string becomes very unreadable...

Cheers!

  • 2
    Solidity doesn't support operator overloading. – Ismael Feb 1 '18 at 21:02
  • @Ismael thank you! I do remember reading something about this in a Vitalik blog post, but I don't recall the specifics. Perhaps in the future... – Alex Feb 2 '18 at 5:47
2

The official solidity documentation only mentions function overloading.

There is no operator overloading in Solidity.

1

No, Solidity doesn't support operator overloading as of Jan 2018.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.