Skip to content

Instantly share code, notes, and snippets.

@hinrik
Created November 15, 2017 19:34
Show Gist options
  • Save hinrik/69bbc9feb263f82f830d6233e8abf396 to your computer and use it in GitHub Desktop.
Save hinrik/69bbc9feb263f82f830d6233e8abf396 to your computer and use it in GitHub Desktop.
require "option_parser"
class Foo
@filename : String
def initialize(@filename)
end
end
filename = nil
#OptionParser.parse! do |parser|
# parser.on("-f FILE", "Filename") do |file|
# filename = file
# end
#end
if filename
# if I uncomment the code above, this fails with:
# instance variable '@filename' of Foo must be String, not (String | Nil)
Foo.new(filename)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment