3 回答
TA贡献1891条经验 获得超3个赞
[T: Bound]
T
Bound[T]
.
tabulate
def tabulate[T](len: Int, f: Int => T) = { val xs = new Array[T](len) for (i <- 0 until len) xs(i) = f(i) xs}
Array[T]
ClassManifest[T]
def tabulate[T](len: Int, f: Int => T)(implicit m: ClassManifest[T]) = { val xs = new Array[T](len) for (i <- 0 until len) xs(i) = f(i) xs}
T
def tabulate[T: ClassManifest](len: Int, f: Int => T) = { val xs = new Array[T](len) for (i <- 0 until len) xs(i) = f(i) xs}
TA贡献1871条经验 获得超13个赞
A <% B
<:
A : C
T
Manifest
Ordered
Ordering
def example[T <% Ordered[T]](param: T)
Ordered
def example[T : Ordering](param: T)
Ordering
.
ClassManifest
TA贡献1831条经验 获得超10个赞
scala> implicit def int2str(i: Int): String = i.toString int2str: (i: Int)Stringscala> def f1[T <% String](t: T) = 0f1: [T](t: T)(implicit evidence$1: (T) => String)Int
F
T
.
scala> trait To[T] { type From[F] = F => T } defined trait Toscala> def f2[T : To[String]#From](t: T) = 0 f2: [T](t: T)(implicit evidence$1: (T) => java.lang.String)Intscala> f2(1)res1: Int = 0
* => *
Function1
(*, *) => *
String
def f3[T : [X](X => String)](t: T) = 0
- 3 回答
- 0 关注
- 426 浏览
添加回答
举报