Guest User

Untitled

a guest
Feb 16th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class ['a1] a1 = object (self : 'a1)
  2.  
  3. val a2 : _ #a2 option ref = ref None
  4. method set a2' = a2 := Some a2'
  5. method get = match ! a2 with
  6. | Some a2 -> a2
  7. | None -> raise Not_found
  8.  
  9. end
  10.  
  11. and ['a2] a2 = object (self : 'a2)
  12.  
  13. val a1 : _ #a1 option ref = ref None
  14. method set a1' = a1 := Some a1'
  15. method get = match ! a1 with
  16. | Some a1 -> a1
  17. | None -> raise Not_found
  18.  
  19. end
  20.  
  21.  
  22. let x = new a1
  23. and y = new a2
  24.  
  25. let _ =
  26. x#set (y :> _ a2);
Add Comment
Please, Sign In to add comment