Skip to content

Instantly share code, notes, and snippets.

@coreymartella
Created January 10, 2012 03:00
Show Gist options
  • Save coreymartella/1586608 to your computer and use it in GitHub Desktop.
Save coreymartella/1586608 to your computer and use it in GitHub Desktop.
version compare
print "version1:";STDOUT.flush
v1 = gets.strip.split(".").map(&:to_i)
print "\nversion2:";STDOUT.flush
v2 = gets.strip.split(".").map(&:to_i)
diff = v1 <=> v2
puts "v1 < v2" if diff < 0
puts "v1 = v2" if diff == 0
puts "v1 > v2" if diff > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment