Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想测试我的案例类构造函数的参数,如果它们未通过某些测试,则抛出异常。当我尝试编写自己的应用方法时编译器抱怨(多个“应用”方法。
我想我可以让它成为一个非案例类,并自己做应用/取消应用构造函数字段的东西,但我不希望这样做。
谢谢
case class Picky(i: Int, s: String) { require(i % 2 == 0, "i must be even") require(s.length < 50, "s length must be less than 50 characters") // ... }