共通エンリッチマイライブラリパターンがメソッドを暗黙的にマークすることができますが、コンストラクタではないのはなぜですか?
class Foo(value: Int)
implicit def int2Foo(i: Int) = new Foo(i)
なぜそれだけでコンストラクタことを考えると、この
class Foo implicit (value: Int)
のようなコンストラクタ自体にimplicit
を追加することはできませんのようなもののようですいくつかの追加制限付きの方法ではありませんか?
驚くべきことに、以下の作業を行います。
class Foo(value: Int) {
implicit def this(a: String) = this(a.toInt)
}
[Pimp My Library](http://www.artima.com/weblogs/viewpost.jsp?thread=179766)ではありませんか?もしそうなら、[そのためのタグ](http://stackoverflow.com/questions/tagged/pimp-my-library)があります。 – huitseeker
はい、私はそれを意味しました... :-) – soc
FYI:https://issues.scala-lang.org/browse/SI-4882 – gerferra