3 ms·
Clearly, you haven't even bothered to read up about Kotlin. (a == 1).ifTrue { // ... }.else { // ... } is standard Kotlin with its DSL
by hota_mazi 8y ago
Clearly, you haven't even bothered to read up about Kotlin.
(a == 1).ifTrue {
// ...
}.else {
// ...
}
is standard Kotlin with its DSL syntax.
`ifTrue` and `else` are extension methods added to the `Boolean` type.
You know that there have been new developments in PLT since Smalltalk, right?
- gambler 8y ago>`ifTrue` and `else` are extension methods added to the `Boolean` type. You don't seem to understand what this discussion is about. Extension functions in Kotlin are statically dispatched, so while they are a nice feature, they are completely irrelevant here. It's not about how your invocation code looks like. The important part is that at some point the code needs to make a decision whether to invoke "if" case or "else" case. Smalltalk achieves this by having two objects/classes (True and False) that handle the same message differently. The implementation of those objects does not have a hidden control flow statement. Your code would.