I have a grails object that I want to extract the first value in it. I’m new to grails and not understanding the language fully yet.
I used a loop to extract them before but this time I just need the first value and nothing else.
I tried just using
<div id="blaa">${items}[0].value"</div>
That threw an error.
Below is usually how I would loop through the object.
<g:each in="${items}" var="item" status="i">
<li><a href="#">${item.value}</a></li>
</g:each>
Making some assumptions here because you’re not showing a lot of code and you also didn’t tell us the error:
By default collections in Grails are Sets. To get the first value in a set you could do something like: