multiple_dispatch.sf 359 B

1234567891011121314151617181920212223
  1. #!/usr/bin/ruby
  2. func test(String a){
  3. say "Got a string: #{a}";
  4. }
  5. func test(Number n) {
  6. say "Got a number: #{n}";
  7. }
  8. func test(Number n, Array m) {
  9. say "Got a number: #{n} and an array: #{m.dump}";
  10. }
  11. func test(String s, Number p) {
  12. say "Got a string: #{s} and a number: #{p}";
  13. }
  14. test("hello", 21);
  15. test("sidef");
  16. test(12, [1,1]);
  17. test(42);