Skip to content

Instantly share code, notes, and snippets.

@hisanari
Created October 9, 2017 00:10
Show Gist options
  • Save hisanari/1e7a51d7b2b06dce4718b23f48ee9e2b to your computer and use it in GitHub Desktop.
Save hisanari/1e7a51d7b2b06dce4718b23f48ee9e2b to your computer and use it in GitHub Desktop.
arr1=[1,2,3,4,5]
arr2=[1,2,3,4,5]
arr3=[1,2,3,4]
arr4=[1,2,3,5]
arr5=[1000,2000,3000]
arr6=[1,2]
arr7=[2,1]
arr8=["hello", "world"]
arr9=["Hello", "World"]
# 0が返ってくる
p(arr1<=>arr2) #1
# -1
p(arr3<=>arr1) #2
# 1
p(arr4<=>arr3) #3
# 1
p(arr5<=>arr4) #4
# 1
p(arr7<=>arr6) #5
# nil
p(arr8<=>arr7) #6
# -1
p(arr9<=>arr8) #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment