fork download
  1. class cell =
  2. object
  3. val mutable contents = 0
  4. method get = contents
  5. method set x = contents <- x
  6. end;;
  7.  
  8. let makecell =
  9. object
  10. val mutable contents = 0
  11. method get = contents
  12. method set x = contents <- x
  13. end;;
  14.  
  15. let test c x =
  16. c#set x;
  17. print_int c#get;;
  18.  
  19. test (new cell) 1;;
  20. test (makecell) 2;;
Success #stdin #stdout 0.01s 2736KB
stdin
Standard input is empty
stdout
12