Skip to content

Instantly share code, notes, and snippets.

@sochoa
Created January 21, 2013 08:04
Show Gist options
  • Save sochoa/4584428 to your computer and use it in GitHub Desktop.
Save sochoa/4584428 to your computer and use it in GitHub Desktop.
Could I have done this better, in ruby?
#!/usr/bin/env ruby
require 'trollop'
opts = Trollop::options do
banner <<-EOS
Reverses a string.
Usage:
ruby reverse.rb [options]
Options:
EOS
opt :input, "String to reverse", :type => :string, :short => "-i"
end
Trollop::die :input, "flag is required" if opts[:input] == nil
opts[:input].split("").reverse.each do |i|
print i
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment