Scala case class instantiate when you have not-used-in-equals properties -


have academic class:

case class a3(name: string)(val s: string) {} 

trying instantiate it. tried

  1. val v = a3("la")
  2. val v = a3("la", "ba")

neither worked. looked @ book, http://techbus.safaribooksonline.com/book/programming/scala/9780981531687/case-classes-and-pattern-matching/case_classes_and_pattern_matching_html

i googled not answer.

scala ide messages did not (correction : do, tool tip box not big enough , had black background, missed important part, see below repl output). repl helped, need use 2 sets of parenthesis like:

val v = a3("ga")("mu") 

full repl:

scala> case class a3(name: string)(var s : string) {} defined class a3

scala> val v3 = a3("a2") :13: error: missing argument list method apply in object a3 unapplied methods converted functions when function type expected. can make conversion explicit writing apply _ or apply(_)(_) instead of apply. val v3 = a3("a2") ^

scala> val v3 = a3("a2")("s") v3: a3 = a3(a2)


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -