4
我想知道,是否有相当于python的pass表达式?这个想法是编写没有实现的方法签名,并编译它们只是为了对某些库原型的签名进行类型检查。我能种模拟使用本这样的行为:现在斯卡拉和Python的通行证
def pass[A]:A = {throw new Exception("pass"); (new Object()).asInstanceOf[A]}
当我写:
def foo():Int = bar()
def bar() = pass[Int]
它的工作原理(这typechecks但运行时发生爆炸,这是很好的),但我的实现没有按”感觉不错(例如使用java.lang.Object())。有没有更好的方法来模拟这种行为?
???是史上最好的方法名称。 –