Call an object method: Difference between revisions

m
→‎{{header|Kotlin}}: changed syntax highlight to kotlin
(Replace println() with print(); replace output "syntaxhighlight" tag with "pre" tag)
m (→‎{{header|Kotlin}}: changed syntax highlight to kotlin)
Line 811:
masskg(x) = x.weight
=={{header|Kotlin}}==
Kotlin does not have static methods as such, but they can be easily simulated by '<code>companion object'</code> methods :.
 
<syntaxhighlight lang="scalakotlin">class MyClass {
fun instanceMethod(s: String) = println(s)
 
Line 820 ⟶ 821:
}
 
fun main(args: Array<String>) {
val mc = MyClass()
mc.instanceMethod("Hello instance world!")
Line 831 ⟶ 832:
Hello static world!
</pre>
 
=={{header|Latitude}}==
 
32

edits