Top 1,000 Features Creators Resources Extensions Blog Explorer CSV Download
GitHub icon

Operator Overloading

< >
Example from 1 languages: Python
# Python Program illustrate how # to overload an binary + operator class A: def __init__(self, a): self.a = a # adding two objects def __add__(self, o): return self.a + o.a ob1 = A(1) ob2 = A(2) ob3 = A("Geeks") ob4 = A("For") print(ob1 + ob2) print(ob3 + ob4)
Example from 1 languages: C3
fn int IntList.get(IntList* this, int idx) @operator([]) { return this.vals[idx]; } ... IntList x = ... foo(x[1]);
Example from 1 languages: Wolfram Language
f[x_Integer] := x^2; f[x_String] := "not a number"; f[x_Symbol] := x^2;
Example from 1 languages: Speedie
str = "a" + "b" array <~ str
*

Languages with Operator Overloading include Python, C++, Perl, Ruby, PHP, C#, R, Swift, Rust, Scala, Lua, MATLAB, Haskell, Kotlin, Clojure, Dart, Ada, D, Groovy, F#, Smalltalk, Visual Basic .NET, Eiffel, C3, Wolfram Language, Ceylon, Raku, Io, Object Pascal, FreeBASIC, Seed7, Free Pascal, Speedie

*

Languages without Operator Overloading include JavaScript, C, Java, Go, TypeScript, Objective-C, Visual Basic, Pascal, BASIC, progsbase, Modula-2, Veryl, Jule

*

View all concepts with or missing a hasOperatorOverloading measurement

*

Read more about Operator Overloading on the web: 1. 2.

View source

- Build the next great programming language About Acknowledgements Part of the World Wide Scroll