1 Go
Variable
var myvariable1, myvariable2, myvariable3 = 2, "GFG", 67.56
var i, j = os.Open(name)
var i, j = os.Open(name)
Using short variable declaration
myvar1, myvar2, myvar3 := 800, "Geeks", 47.56
i, j := os.Open(name)
i, j := os.Open(name)
Constant
const PI = 3.14
2 Rust
Variable
let x = 5; // Can’t change that value.
let mut x = 5;
let mut x = 5;
Constant
const THREE_HOURS_IN_SECONDS: u32 = 60 * 60 * 3;
- Use var or short variable declaration define variables in Go.
- By default variables are immutable in Rust.
- Both use const to define constant.
- Constants must be explicitly typed in Rust.
No comments:
Post a Comment