Hi Benas IML,

> I'd also like to mention that other languages don't have any kind of
> syntactic sugar/special syntax for iterating over keys. That is achieved
> using a function though.

That's not true, Golang has iterating over keys by default and a more verbose 
syntax to iterate over values.
https://gobyexample.com/range
`_` is used to indicate to the compiler that the result should be discarded.


```
    // range on map iterates over key/value pairs.
    kvs := map[string]string{"a": "apple", "b": "banana"}
    for k, v := range kvs {
        fmt.Printf("%s -> %s\n", k, v)
    }
    // iterate over just the keys of a map.
    for k := range kvs {
        fmt.Println("key:", k)
    }
    // iterate over just the values of a map.
    for _, v := range kvs {
        fmt.Println("key:", k)
    }
```

Cheers,
- Tyson
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to