All Go Rust Python PHP JavaScript
Chrome Dev Summit to secure your spot in workshops, office hours and learning lounges!

How to Iterate Over a Slice in Reverse in Go

In Golang, there are 2 ways to iterate over a slice in reverse. Using For Loop There is no convenient operator for this to add to the range one in place. You'll have to do a normal for loop counting down. See the following example: package main...
Patcher56

How to Iterate through the Values of an Enum in Rust

In Rust, there are 2 ways to iterate through the values of an enum. Using a static array If the enum is C-like, then you can create a static array of each of the variants and return an iterator of references to them: use self::Direction::*; use...
pooriabt

How to Make a Reverse Ordered For Loop in Rust

In Rust, using the rev() function is the easiest way to make a reverse ordered for loop. Using rev Function The .rev() function reverses an iterator’s direction. Usually, iterators iterate from left to right. After using rev(), an iterator will ins...
aweis

How to Iterate Over a String by Character in Rust

In Rust, there are 3 ways to iterate over a string by character. Using chars Method The chars() method returns an iterator over the chars of a string slice. See the following example: fn main() { let s = "abc"; for c in s.chars() { pr...
pooriabt

How to use range in Go

Range loop (for-each) patterns.For-each Loop (slice or map) The range form of the for loop iterates over a slice or map. When ranging over a slice, two values are returned for each iteration. The first is the index, and the second is a copy of the el...
Unused

How many keywords are there in Go

List of Golang Keywords. Keywords The following keywords are reserved and may not be used as identifiers. break default func interface select case defer go map struct chan else goto package switch const ...
Sambhav Khandelwal