1
scala> "Foo".capitalize(2)    
res18: Char = o
4

1 回答 1

6

复制自StringLike 特征文档

def capitalize: String
Returns this string with first character converted to upper case

你实际上在做的是

“Foo”.capitalize.apply(2)

文档再次:

def apply(n: Int): Char
Return element at index n
于 2013-02-13T07:58:55.850 回答