Reputation: 411
I have a function which receives a sequence of two user defined classes:
tags: Seq[(tag, pattern)]
I want to access each element of sequence then access to fields belonging to tag and pattern from that element. I am able to print all sequence lines using:
for(i <- tags)
{
println("Tags for i are " + i)
}
But how can I access tag and pattern from i?
Upvotes: 0
Views: 291
Reputation: 11508
You can use:
for ((t, p) <- tags) {
println(s"Tag: $t Pattern: $p")
}
Upvotes: 1