Overload.k 622 B

12345678910111213141516171819202122232425262728293031
  1. invoke {
  2. function f (x: Int) -> Int {
  3. return x + 1
  4. }
  5. function f (x: String) -> String {
  6. return x + '1'
  7. }
  8. assert f is not Function
  9. assert f is Overload
  10. assert f(3) == 4
  11. assert f('3') == '31'
  12. function g (x: Int, y: Int) -> Int {
  13. return x + y
  14. }
  15. function g (x: Int, y: Int) -> Int {
  16. return x * y
  17. }
  18. assert g(5,3) == 15
  19. invoke {
  20. function g (x: Int) -> Int {
  21. return x*x
  22. }
  23. assert g(7) == 49
  24. assert g(7,9) == 63
  25. invoke {
  26. let g = Nil
  27. assert g is Nil
  28. }
  29. }
  30. }