Samples updated to latest syntax

This commit is contained in:
Maxim Shafirov
2011-01-02 20:06:28 +03:00
parent 6a37d19509
commit b7493012af
20 changed files with 35 additions and 40 deletions
+3 -3
View File
@@ -2,15 +2,15 @@ type Comparison<in T> = {(T, T) : Int}
fun naturalOrder<in T : IComparable<T>>(a : T, b : T) : Int = a.compareTo(b)
fun castingNaturalOrder(a : Object, b : Object) : Int = a.as<Comparable<Object>>.compareTo(b.as<Comparable<Object>>)
fun castingNaturalOrder(a : Object, b : Object) : Int = (a as Comparable<Object>).compareTo(b as Comparable<Object>)
enum class ComparisonResult {
LS,EQ, GR
LS, EQ, GR
}
type MatchableComparison<in T> = {(T, T) : ComparisonResult}
fun asMatchableComparison<T>(cmp : Comparison<T>) : MatchableComparison<T> = {a, b =>
fun asMatchableComparison<T>(cmp : Comparison<T>) : MatchableComparison<T> = {(a, b) =>
val res = cmp(a, b)
if (res == 0) return ComparisonResult.EQ
if (res < 0) return ComparisonResult.LS
+1 -1
View File
@@ -1,3 +1,3 @@
interface class IComparable<in T> {
virtual class IComparable<in T> {
fun compareTo(other : T) : Int
}