Skip to content

Instantly share code, notes, and snippets.

@pbyrne
Created February 6, 2020 15:56
Show Gist options
  • Save pbyrne/0bfa8ab126ea1ce7f9ae1a090b5ea395 to your computer and use it in GitHub Desktop.
Save pbyrne/0bfa8ab126ea1ce7f9ae1a090b5ea395 to your computer and use it in GitHub Desktop.

Bash

ar1=(1); ar2=(1); [ $ar1 = $ar2 ] && echo true || echo false
true

Python

>>> [1] == [1]
True

Rust

fn main() {
    println!("{}", [1] == [1]);
}
true

Swift

let ar1 = [1]
let ar2 = [1]
print(ar1 == ar2)
true

Go

(This one's a little tricky because == isn't defined for slices. So maybe apples to oranges.)

Go
package main

import (
	"fmt"
	"reflect"
)

func main() {
	ar1 := []int{1}
	ar2 := []int{1}	
	
	fmt.Println(reflect.DeepEqual(ar1, ar2))
}
true

Ruby

[1] == [1]
# => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment