Function prototype: Difference between revisions
Content added Content deleted
(Added C#) |
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
||
Line 623: | Line 623: | ||
fun ooo(o: Int = 1): Int // optional argument with default value and return type Int |
fun ooo(o: Int = 1): Int // optional argument with default value and return type Int |
||
fun roo(): Int // no arguments with return type Int |
fun roo(): Int // no arguments with return type Int |
||
val poo |
val poo: Int // read only property of type Int |
||
} |
|||
} |
|||
abstract class MyAbstractClass { |
abstract class MyAbstractClass { |
||
protected constructor() |
|||
abstract fun afoo() // abstract member function, no arguments or return type |
abstract fun afoo() // abstract member function, no arguments or return type |
||
abstract var apoo: Int // abstract read/write member property of type Int |
abstract var apoo: Int // abstract read/write member property of type Int |
||
Line 634: | Line 633: | ||
class Derived : MyAbstractClass(), MyInterface { |
class Derived : MyAbstractClass(), MyInterface { |
||
override fun afoo() {} |
override fun afoo() {} |
||
override var apoo: |
override var apoo: Int = 0 |
||
override fun foo() {} |
override fun foo() {} |
||
override fun goo(i: Int, j: Int) {} |
override fun goo(i: Int, j: Int) {} |
||
override fun voo(vararg v: Int) {} |
override fun voo(vararg v: Int) {} |
||
override fun ooo(o: Int):Int = o // can't specify default argument again here but same as in interface |
override fun ooo(o: Int): Int = o // can't specify default argument again here but same as in interface |
||
override fun roo(): Int = 2 |
override fun roo(): Int = 2 |
||
override val poo |
override val poo: Int = 3 |
||
} |
} |
||
fun main(args: Array<String>) { |
fun main(args: Array<String>) { |