Scala's tuple unwrapping nuance

后端 未结 3 2026
轻奢々
轻奢々 2021-02-02 14:57

I\'ve noticed the following behavior in scala when trying to unwrap tuples into vals:

scala> val (A, B, C) = (1, 2, 3)
:5: error: not found: va         


        
3条回答
  •  执念已碎
    2021-02-02 15:55

    From [scala] Question about naming conventions you can read

    The initial capital letter has an advantage when pattern matching. Identifiers with an initial capital letter are considered to be values to match against instead of a variable to be bound.

提交回复
热议问题