# Optional Parameters困惑

**URL:** <https://taolun.moonbitlang.com/t/topic/1076>\
**Category:** 代码帮助\
**Created:** [2024 年12 月 12 日 07:24 UTC](https://taolun.moonbitlang.com/t/topic/1076 "2024-12-12T07:24:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

作者： ![jimwei](https://taolun.moonbitlang.com/letter_avatar_proxy/v4/letter/j/4da419/32.png) [@jimwei](https://taolun.moonbitlang.com/u/jimwei)\
发布日期： [2024 年12 月 12 日 07:24 UTC](https://taolun.moonbitlang.com/t/topic/1076/1 "2024-12-12T07:24:56Z")

</div>

fn test(a: Int, b?: Int) → Unit {  
}

对这个函数的调用  
test(1) // ok  
test(1, 2) // error  
test(1, b = 2) // ok

第二种调用方式失败， 不太理解为什么， 文档中也没有这种例子，麻烦给解释一下， 谢谢~~~

---

<div class="post-metadata">

作者： ![ChenYubin](https://taolun.moonbitlang.com/letter_avatar_proxy/v4/letter/c/ee59a6/32.png) [@ChenYubin](https://taolun.moonbitlang.com/u/ChenYubin)\
发布日期： [2024 年12 月 13 日 01:55 UTC](https://taolun.moonbitlang.com/t/topic/1076/2 "2024-12-13T01:55:00Z")

</div>

`b? : Int` `b~ : Int` 这种是label argument，调用时必须显式指定参数名
