这个用于指定类型参数的 Scala 中缀语法的名称是什么? [英] What's the name of this Scala infix syntax for specifying type params?

查看:37
本文介绍了这个用于指定类型参数的 Scala 中缀语法的名称是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前几天我注意到这个有趣的语法,用于为 Scala 类指定类型参数.

I noticed this interesting syntax the other day for specifying the type parameters for a Scala class.

scala> class X[T, U]
defined class X

scala> new (Int X Int)
res1: X[Int,Int] = X@856447

这种语法有名字吗?它有什么好的用例?

Is there a name for this sort of syntax? What's a good use case for it?

推荐答案

它只是一个二进制类型构造函数的中缀应用.与方法的中缀应用一样,当类型构造函数或方法的名称包含标点符号时,它更常用.2.8 库中的示例包括 <:<<%<=:=(请参阅 scala.Predef).

It's just infix application of a binary type constructor. As with infix application of methods, it's more commonly used when the name of the type constructor or method comprises punctuation characters. Examples in the 2.8 library include <:<, <%< and =:= (see scala.Predef).

这篇关于这个用于指定类型参数的 Scala 中缀语法的名称是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆