Skip to content

Instantly share code, notes, and snippets.

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