Call an object method: Difference between revisions

Added Dyalect programming language
(Added Dyalect programming language)
Line 259:
assert(d.dynamicMethod() == "Woof!");
}</lang>
 
=={{header|Dyalect}}==
 
Dyalect supports both instance and static methods. Instance methods have a special <code>this</code> reference that returns an instance. Static method are always invoked through the type name.
 
<lang dyalect>//Static method on a built-in type Integer
static func Integer.div(x, y) {
x / y
}
 
//Instance method
func Integer.div(n) {
this / n
}
 
print(Integer.div(12, 3))
print(12.div(3))</lang>
 
{{out}}
 
<pre>4
4</pre>
 
=={{header|E}}==
Line 267 ⟶ 289:
 
In E, there are no distinguished "static methods". Instead, it is idiomatic to place methods on the maker of the object. This is very similar to methods on constructors in JavaScript, or class methods in Objective-C.
 
=={{header|Elena}}==
The message call:
Anonymous user