June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,13 @@
|
|||
function add(a, b)
|
||||
try
|
||||
a + b
|
||||
catch
|
||||
println("caught exception")
|
||||
a * b
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
println(add(2, 6))
|
||||
println(add(1//2, 1//2))
|
||||
println(add("Hello ", "world"))
|
||||
|
|
@ -1,18 +1,14 @@
|
|||
// Kotlin JS version 1.1.4-3
|
||||
// Kotlin JS version 1.2.0 (Firefox 43)
|
||||
|
||||
class C // class with no methods
|
||||
class C {
|
||||
// this method prevents a TypeError being thrown if an unknown method is called
|
||||
fun __noSuchMethod__(id: String, args: Array<Any>) {
|
||||
println("Class C does not have a method called $id")
|
||||
if (args.size > 0) println("which takes arguments: ${args.asList()}")
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val c: dynamic = C() // 'dynamic' turns off compile time checks
|
||||
try {
|
||||
c.foo() // the compiler now allows this call even though foo() is undefined
|
||||
}
|
||||
catch (t: Throwable) {
|
||||
if (t.message == "undefined is not a function") {
|
||||
println("Class C does not have a method called foo")
|
||||
}
|
||||
else {
|
||||
println(t.message)
|
||||
}
|
||||
}
|
||||
c.foo() // the compiler now allows this call even though foo() is undefined
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue