Issue with get() indexing

Hi everyone,

I’m struggling with getting specific values out of an array with the get function.

The raw names of the array are numbers 0 to 5. Meaning, if I want to get specific values out of the array with the get function, I have to use 0-5 with dot notation. It works perfectly for entries like 1.1, 3.2, 3.4., 5.1., 0.2, 0.4 etc.

But if I want to get to the first values in the array, the ones with raw name “0”, I have to use “1.0”, 2.0", “3.0” etc. Every time I type that and click save on a module, make changes “1.0” to “1”, “2.0” to “2” and so on. And since “1” without dot notation doesn’t work in the get function, I get error messages.

So my question is, how do I get to first values in an array, if indexing starts with 0 and the raw name is “0”? Or how do I prevent make from automatically changing e.g. “2.0” to “2”?

Welcome to the Make community!

You can use the built-in function first.

It’s as simple as that!

2 Likes

Interesting, was not aware of that. Thank you.

But does that mean it’s intentional behaviour for the get function not to be able to get the first element by dot notation? e.g. “1.0” is supposed not to work?

That’s because your keys are strings.

You could probably type {{1.`0`}}

2 Likes