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

How to Recover panic in Golang

Defer, Panic, and Recover in Go. panic During a typical panic, normal execution stops, all deferred function calls in that goroutine are executed, and the program crashes with a log message. package main func main() { panic("invalid") } ...
Unused

How to Use Deferred Function Calls in Golang

Understanding defer in Go. Deferred Function Calls A defer statement is an ordinary function or method call prefixed by the keyword defer. The function and argument expressions are evaluated when the statement is executed, but the actual call is def...
ada

How to Reverse a String in Rust

In Rust, there are 2 ways to reverse a string. Using rev Function The str::rev() function reverses an iterator’s direction. See the following example: fn main() { let mut s = "Hello"; println!("{}", s.chars().rev().collect::<String>());...
pooriabt

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 Reverse a String in Python

In Python, there are 3 ways to reverse a string. Using slicing Slice notation takes the form [start:stop:step]. #!/usr/bin/python3 s = "Hello World" print(s[::-1]) # syntax # a[start:stop] # items start through stop-1 # a[start:] # items...
pooriabt

How to Check If an Object Is of a Given Type in Python

In Python, there are 2 ways to check if an object is of a given type. Using isinstance Method The isinstance(object, classinfo) method returns True if the object argument is an instance of the classinfo argument, or of a (direct, indirect, or virtua...
Unused

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 reverse a slice in Go

Reverse a Slice in Golang.Using a for Loop The standard library does not have a built-in function for reversing a slice. Use a for loop to reverse a slice: package main import "fmt" func main() { s := []string{"b", "c", "d"} for i := len(s)/...
ada

How to reverse a string in Go

Reverse a String in Golang.Using range a range on a string returns a rune which is a codepoint. package main import "fmt" func Reverse(s string) (result string) { for _, v := range s { result = string(v) + result } return } func main() ...
Tomoki

How to reverse an array in PHP

Reverse the order of an array.Using array_reverse Function The array_reverse() return an array with elements in reverse order. $arr = array("PHP", 8.1, 4); $reversed = array_reverse($arr); print_r($reversed); $preserved = array_reverse($arr, true);...
aweis

How to reverse a string in PHP

Reverse a Unicode String in PHP.Using strrev Function The strrev() reverse a string. // !olleH echo strrev("Hello!"); // does not support utf-8 encoding strrev("Hello,世界"); !olleH Using For Loop FOR LOOP will start with the value of the length o...
Tomoki

How to use the curl command in Linux

command line tool and library for transferring data with URLs. cURL (pronounced 'curl') is a computer software project providing a library (libcurl) and command-line tool (curl) for transferring data using various network protocols. The name ...

How to use the ls command in Linux

List Files and Directories.The ls command lists files and directories within the file system, and shows detailed information about them. It is a part of the GNU core utilities package which is installed on all Linux distributions. List all files, in...

How to use the Angular CLI serve command line

Builds and serves your app, rebuilding on file changes. ng serve is a great command to use when developing your application locally. It starts up a local development server, which will serve your application while you are developing it. It is not mea...