Again got the same error unexpected ":=" in operand
Sorry for silly question, but I don’t undestand Scratch at all. For me it looks like artifical crutch to solve problems not existing in Python, JS, PHP and other languages I usually practice.
Nope. This operation not changed target map element (first element in my case), just appended one more element:
[
map[name:Tag B permalink:/tags/tag-b/ sort:b]
map[name:Tag C permalink:/tags/tag-c/ sort:c]
map[name:Tag A permalink:/tags/tag-a/ sort:a]
map[sort:d]
]
I suppose that (like in many other languages) you can’t assign to an expression. And since there’s no way to get a reference to an array element, you’re probably out of luck here.
Maybe it helps to describe what you want to achieve in more abstract terms to find another solution?
The matter is not about “assign to expression”, but to modify existing non-const data structure. The basic instrumentary of any common language. Working example in javascript:
Thanks, but I knew that. I just pointed out what you were doing in your Hugo code. In my experience, it is quite pointless to compare languages, and I’m sure that Go itself permits what you want. But here we’re talking about a template language, which is apparently lacking features in comparison to others.
That’s why I was asking about your goal and musing if it might be possible to achieve it in a way that’s actually possible in Hugo.
So I’m far away of comparing languages, just looking for instrumentary that allows me to reach the goal - process some custom structured data. My previous topic here referring to the same goal.
Thank you! Such way of data manipulation is a new dimension in my Hugo experience.
Regarding initial topic. Significant benefit of static site generators is that excessive and not speed/data/size optimized code runs only on local machine and not taking much more valuable web server resources. So I’ve already launch a straightforward (and not too elegant) workaround solution via intermediate array. But definitely will test your solution.