3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Scalaの中置記法まとめ

Posted at

「中置構文」と記されることもある。
具体例は下のサンプルコードの通り。

まとめ

  1. 引数1つの関数の場合、 .() を省略して二項演算子として記述可能
  2. 更に、名前の最後の文字が : の場合、右結合となり、左右の項の位置が入れ替わる
  3. 2つの型パラメータを持つジェネリックな型は中置記法で書くことができる1
典型例
5 + 3 // 5.+(3)
1 :: List(2, 3) // List(2, 3).::(1) = List(1, 2, 3)
Command ~> Id // ~>[Command, Id]

参考

脚注

  1. Scala変態技法最速マスター - kmizuの日記より引用。型エイリアスを使うケースが多そう

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?