This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = true; | |
let b = false; | |
let c = !a; //false | |
let d = a && b; //false | |
let e = a || b; //true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = 1; | |
let b = 2; | |
let c = a & b; //0 (01 && 10 -> 00) | |
let d = a | b; //3 (01 || 10 -> 11) | |
let e = a ^ b; //3 (01 != 10 -> 11) | |
let f = a << b; //4 (add 2 positions to the end -> '01'+'00' -> 100) | |
let g = a >> a; //0 (remove 2 positions from the end -> o̶1̶ -> 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = !-2; //1 | |
let b = !-1; //0 | |
let c = !0; //-1 | |
let d = !1; //-2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut a = 2; | |
a += 5; //2 + 5 = 7 | |
a -= 2; //7 - 2 = 5 | |
a *= 5; //5 * 5 = 25 | |
a /= 2; //25 / 2 = 12 not 12.5 | |
a %= 5; //12 % 5 = 2 | |
a &= 2; //10 && 10 -> 10 -> 2 | |
a |= 5; //010 || 101 -> 111 -> 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let a = 15; | |
let b = (a as f64) / 2.0; //7.5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$isCron = 'cli' === strtolower(PHP_SAPI); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
screen -S dumindu | |
pv /home/usera/download/public/db_dump.sql.gz | gunzip | mysql db_name; | |
#exit from screen without terminating task | |
ctrl ad | |
#to check back | |
screen -r dumindu | |
#to terminate | |
ctrl d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Creating vectors - 2 ways | |
let mut a = Vec::new(); //1.with new() keyword | |
let mut b = vec![]; //2.using the vec! macro | |
//Creating with data types | |
let mut a2: Vec<i32> = Vec::new(); | |
let mut b2: Vec<i32> = vec![]; | |
let mut b3 = vec![1i32, 2, 3];//sufixing 1st value with data type | |
//Creating with data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mut v = vec![1, 2, 3, 4, 5]; | |
for i in &v { | |
println!("A reference to {}", i); | |
} | |
for i in &mut v { | |
println!("A mutable reference to {}", i); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Struct Declaration | |
struct Color { | |
red: u8, | |
green: u8, | |
blue: u8 | |
} | |
fn main() { | |
// creating an instance | |
let black = Color {red: 0, green: 0, blue: 0}; |