mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
- Introduce new 'rem' operator convention - Prefer 'rem()' to 'mod()' when both are available, even if mod() is a member, and rem() -- an extension - Place operator 'rem' under the language feature
18 lines
296 B
Kotlin
Vendored
18 lines
296 B
Kotlin
Vendored
class A() {
|
|
var x = 5
|
|
|
|
operator fun mod(y: Int) { throw RuntimeException("mod has been called instead of rem") }
|
|
operator fun rem(y: Int) { x -= y }
|
|
}
|
|
|
|
fun box(): String {
|
|
val a = A()
|
|
|
|
a % 5
|
|
|
|
if (a.x != 0) {
|
|
return "Fail: a.x(${a.x}) != 0"
|
|
}
|
|
|
|
return "OK"
|
|
} |