KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Greetings, How can I make the Foo constructor visible only to this package (unit test + companion object) ? I don't want to be able to instantiate Foo outside of this 2 files... Foo.scala package project.foo class Foo(val value: String) object Foo { def generate: Foo = new Foo("test") } FooSpec.scala package project.foo import org.spec2.mutable._ class FooSpec extends Specification { "Foo" should { "be constructed with a string" { val foo = new Foo("test") foo.value must be "test" } } } I'm using Scala 2.9
Tags (comma-separated)
Save Edits
Cancel