[ create a new paste ] login | about

Link: http://codepad.org/JrpWJ6Rz    [ raw code | output | fork ]

OCaml, pasted on Dec 15:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
let func obj num =
    if num = 0 then obj#func0
    else obj#func1

class myClass0 =
object
    method func0 = print_string "MyClass0: func0"
end

let x = object
    method func0 = print_string "Anonymous class: func0"
    method func1 = print_string "Anonymous class: func1"
end
let y = new myClass0
let _ = func x 0;
    func x 1;
    func y 0


Output:
1
2
3
4
Line 17, characters 9-10:
This expression has type myClass0 but is here used with type
  < func0 : 'a; func1 : 'a; .. >
The first object type has no method func1


Create a new paste based on this one


Comments: