Scala: Silly things I’ve done.

I had a list of objects, say like this:

val l = List("aaa", "bbb", "ccc")

and I wanted to produce something like this:

<td id=IDaaa>aaa</td>
<td id=IDbbb>bbb</td>
<td id=IDccc>ccc</td>

I first did this:

l.map(u => <td id="ID" + {u}>{u}</td>)

and that failed, unsurprisingly. That’s not even close to valid xml.

The real way is this:

l.map(u => <td id={"ID" + u}>{u}</td>)

This post brought to you by “Expose your Ignorance.”

This entry was posted in General and tagged . Bookmark the permalink.

Comments are closed.