Case Class with more than one param

36 views
Skip to first unread message

Julian Peeters

unread,
Nov 28, 2013, 2:57:09 AM11/28/13
to treehugg...@googlegroups.com
Hi,

Quick question about adding another val to your example case class definition.

(CASECLASSDEF(sym.Var) withParams(VAL("name", StringClass))

For example, how can I output "case class Var(name: String, age: Int)"


Thanks,
-Julian

eugene yokota

unread,
Nov 28, 2013, 3:05:42 AM11/28/13
to treehugg...@googlegroups.com
Hi Julian,

The doc is actually old/wrong, it should be PARAM not VAL. It takes a vararg, so you can just pass more stuff into it.

scala> val tree = (CASECLASSDEF(sym.Var) withParams(PARAM("name", StringClass), PARAM("age", IntClass)): Tree)
tree: treehugger.forest.Tree = ClassDef(Modifiers(case, , Map()),Modifiers(, , Map()),Var,List(),List(ValDef(Modifiers(<param>, , Map()),Typed(Ident(name),TypeTree()),EmptyTree), ValDef(Modifiers(<param>, , Map()),Typed(Ident(age),TypeTree()),EmptyTree)),Template(List(),ValDef(Modifiers(private, , Map()),Ident(_),EmptyTree),List()))

scala> treeToString(tree)
res1: String = case class Var(name: String, age: Int)

-eugene




--
You received this message because you are subscribed to the Google Groups "treehugger-scala" group.
To unsubscribe from this group and stop receiving emails from it, send an email to treehugger-sca...@googlegroups.com.
To post to this group, send email to treehugg...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/treehugger-scala/1f04ba82-4b50-405b-a0e2-6cc5128de523%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Julian Peeters

unread,
Nov 28, 2013, 3:15:25 AM11/28/13
to treehugg...@googlegroups.com

Ah superb. Happy Thanksgiving, grateful for your efforts.

You received this message because you are subscribed to a topic in the Google Groups "treehugger-scala" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/treehugger-scala/0iLPCholPcw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to treehugger-sca...@googlegroups.com.

To post to this group, send email to treehugg...@googlegroups.com.

eugene yokota

unread,
Nov 28, 2013, 3:36:08 AM11/28/13
to treehugg...@googlegroups.com
Same to you! Baking green bean casserole now.

-eugene


Reply all
Reply to author
Forward
0 new messages