dtrovwl75780
dtrovwl75780
2014-12-18 07:45
浏览 22
已采纳

为什么Swift函数定义语法多余?

In C/C++/Java/Go, we use , to separate parameters:

(a int, b int)

In Objective C, we use : to indicate parameters:

:(int)a :(int)b

In Swift, we have to use both : and , :

(a:int, b:int)

Is the redundancy necessary?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • doushizhou4477
    doushizhou4477 2014-12-18 07:50
    已采纳

    Swift might have external and internal parameter names:

    (external internal:Int)
    

    It would create a lot of ambiguity if there wasn't distinctive separators.

    点赞 评论
  • drh19790711
    drh19790711 2014-12-18 08:35

    This is not redundant but simply replacing C's with a :. (And of course turning around type and identifier.)

    点赞 评论

相关推荐