开发者

Setting default argument value in Racket

开发者 https://www.devze.com 2023-03-29 18:19 出处:网络
Is it possible to set a def开发者_高级运维ault value to some of arguments in Racket? Like so in Python:

Is it possible to set a def开发者_高级运维ault value to some of arguments in Racket?

Like so in Python:

def f(arg=0)
    ...


Yes; take a look at: declaring optional arguments.

For example:

(define (f [arg 0])
  (* arg 2))

Racket also supports functions with keyword arguments. The link should lead to documentation that talks about them too. Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消