Lambda - Incrementing a variable in a loop
![Mr_English](https://us.v-cdn.net/6037124/user_avatars/1271230.jpg)
I have an int variable called count_emails.
I wanted to use it as a counter by incrementing it in a foreach loop. I thought a simple example like this would be a good way to start with lambdas.
I tried both of the following, but the value of count_emails remains 1. - see screenshot 2
return $var.count_emails++;
return $var.count_emails = $var.count_emails + 1;
Screenshot 1 shows the code.
Is it possible to create a counter like this? Or have I got the wrong idea?
Screenshot 1
Screenshot 2
Best Answer
-
Hey @Mr_English ! 👋
I recorded this video that explains what is going on with the Lambda:
Check it out, and let me know if you have any questions. 😊
Answers
-
@Liz Anaya Woud it be a good idea to have a category specifially for Lambdas?
-
I've solved the anove requirement of keeping count, using Add Number. Still interested in lambdas though.
-
Hi @Liz Anaya Thank you so much for taking the time to create that video. I had missed the concept of the variables only being referenced, not updated. It really helped.
Tony
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback