PasteRack.org
Paste # 21529
2019-07-03 08:07:43

Fork as a new paste.

Paste viewed 235 times.


Embed:

how to define a default parameter value for a function in t/r?

  1. #lang typed/racket
  2.  
  3. ;; how to define a default parameter value for a function in t/r?
  4.  
  5. (: foo (-> Any Any))
  6. (define (foo [bar 0])
  7.   bar)
  8.  
  9. (foo 1) ; succeeds
  10. (foo) ; type checker error: wrong number of arguments!

=>

- : Any

1

eval:5:0: Type Checker: could not apply function;

 wrong number of arguments provided

  expected: 1

  given: 0

  in: foo