Ask Your Question
2

Tuple pattern in function parameters

asked Dec 19 '11

Johanneke gravatar image Johanneke
77 4 10

According to the documentation you can pattern match parameters in a function declaration, and the pattern for tuples is <first,second,etc>.

Then why is the following code giving a "java.lang.UnsupportedOperationException"?

public void insertRelation(hierarchy(hr), <to,from>) {
  println("hai");
}

When I change it into the following, it does work:

public void insertRelation(hierarchy(hr), tuple[Entity,Entity] r) {
  println("hai");
}

What is going on?

delete close flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
3

answered Dec 30 '11

MarkHills gravatar image MarkHills
351 6 10

This is a bug, which has now been fixed. It should work in the next release. Note that, to "future-proof" the code, you will want to include types on any new variables you introduce inside the patterns, so you would want the tuple pattern to be specified as < Entity to, Entity from > instead of just < to, from >.

link delete flag offensive edit

Comments

Ok, thanks! :)

Johanneke (Dec 30 '11)edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]
Also see the Rascal Tutor.

Question tools

Follow

subscribe to rss feed

Stats

Asked: Dec 19 '11

Seen: 21 times

Last updated: Dec 30 '11