error: No ClassTag available for String

已查看 211 次
跳至第一个未读帖子

Erik Bruchez

未读,
2012年11月15日 20:58:442012/11/15
收件人 scala-i...@googlegroups.com
All,

With 2.10.RC2:

scala> def foo(f: String => Array[String])(s: String) = ()
foo: (f: String => Array[String])(s: String)Unit

scala> foo _
res3: (String => Array[String]) => (String => Unit) = <function1>

scala> foo(Array(_)) _
<console>:9: error: No ClassTag available for String
foo(Array(_)) _
^

This passed with 2.9.2. Bug?

Thanks,

-Erik

Paul Phillips

未读,
2012年11月15日 22:25:222012/11/15
收件人 scala-i...@googlegroups.com


On Thu, Nov 15, 2012 at 5:58 PM, Erik Bruchez <er...@bruchez.org> wrote:
scala> foo(Array(_)) _
<console>:9: error: No ClassTag available for String
              foo(Array(_)) _
                       ^

This passed with 2.9.2. Bug?

Probably, although the trailing _ is not the most specified candle in the candelabrum. This works:

scala> foo(Array(_))(_)
res0: String => Unit = <function1>

Erik Bruchez

未读,
2012年11月15日 23:28:502012/11/15
收件人 scala-i...@googlegroups.com
Thanks for the workaround! I didn't realize the trailing _ was frowned
upon in this case.

-Erik

Eugene Burmako

未读,
2012年11月16日 05:51:042012/11/16
收件人 scala-internals
Just opened a bug: https://issues.scala-lang.org/browse/SI-6673. Will
look into it after lunch.

On Nov 16, 5:29 am, Erik Bruchez <ebruc...@orbeon.com> wrote:
> Thanks for the workaround! I didn't realize the trailing _ was frowned
> upon in this case.
>
> -Erik
>
>
>
>
>
>
>
> On Thu, Nov 15, 2012 at 7:25 PM, Paul Phillips <pa...@improving.org> wrote:
>
回复全部
回复作者
转发
0 个新帖子