Skip to content

Instantly share code, notes, and snippets.

@edgar
Created July 8, 2016 01:20
Show Gist options
  • Save edgar/bfa225fe50099ca3737f86a96bc2b090 to your computer and use it in GitHub Desktop.
Save edgar/bfa225fe50099ca3737f86a96bc2b090 to your computer and use it in GitHub Desktop.
v1 = '0.3.2'
v2 = '0.10.1'
a1 = v1.split('.').map{|v| v.to_i}
a2 = v2.split('.').map{|v| v.to_i}
(a1 <=> a2) < 0 # v1 < v2
=> true
(a1 <=> a2) > 0 # v1 > v2
=> false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment