作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 Scala 中有一个类,目前以标准方式构建:
class Test( int : Int )
{
override def toString() = "Test: %d".format( int )
}
object Test
{
def apply( int : Int ) = new Test( int )
}
@deprecated( "Don't construct directly - use companion constructor", "09/04/13" )
class Test( int : Int )
{
override def toString() = "Test: %d".format( int )
}
scala> Test( 4 )
<console>:10: warning: class Test in package foo is deprecated: Don't construct directly - use companion constructor
val res0 =
^
res0: com.foo.Test = Test: 4
最佳答案
This thread似乎描述了解决方案:
object Test
{
def apply( int : Int ) = new Test( int )
}
class Test @deprecated( "Don't construct directly - use companion constructor", "09/04/13" ) ( int : Int )
{
override def toString() = "Test: %d".format( int )
}
关于Scala 构造函数弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15897014/
我是一名优秀的程序员,十分优秀!