diff --git a/library/src/commonMain/kotlin/net/sergeych/ling/ObjChar.kt b/library/src/commonMain/kotlin/net/sergeych/ling/ObjChar.kt new file mode 100644 index 0000000..733bce5 --- /dev/null +++ b/library/src/commonMain/kotlin/net/sergeych/ling/ObjChar.kt @@ -0,0 +1,19 @@ +package net.sergeych.ling + +class ObjChar(val value: Char): Obj() { + + override val objClass: ObjClass = type + + override suspend fun compareTo(context: Context, other: Obj): Int = + (other as? ObjChar)?.let { value.compareTo(it.value) } ?: -1 + + override fun toString(): String = value.toString() + + override fun inspect(): String = "'$value'" + + companion object { + val type = ObjClass("Char").apply { + addFn("code") { ObjInt(thisAs().value.code.toLong()) } + } + } +} \ No newline at end of file