Skip to content

Priorities of arrow operators variants #11210

@eshu

Description

@eshu

There are different priorities for two variants of arrow operators:

$ scala
Welcome to Scala 2.12.7 (OpenJDK 64-Bit Server VM, Java 1.8.0_181).
Type in expressions for evaluation. Or try :help.

scala> "a" -> "b" -> "c"
res0: ((String, String), String) = ((a,b),c)

scala> "a" → "b" → "c"
res1: ((String, String), String) = ((a,b),c)

scala> "a" → "b" -> "c"
res2: ((String, String), String) = ((a,b),c)

scala> "a" -> "b" → "c"
res3: (String, (String, String)) = (a,(b,c))

scala> "a" + "b" -> "c"
res4: (String, String) = (ab,c)

scala> "a" + "b" → "c"
res5: String = a(b,c)

Unicode arrow "→" has higher priority then "->". Moreover there are some operators that have priority higher than "->" and lower than "→". It was unexpected for me when I got a broken code after replacement "->" with "→".

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions