From 221d689daf4637c7169f9104df0d4b66d00d0370 Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Sun, 4 Sep 2022 14:11:20 +1200 Subject: Re-write source selection to not use the not_nil! method --- src/flint.cr | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/flint.cr b/src/flint.cr index 89f1d3f..02255b2 100644 --- a/src/flint.cr +++ b/src/flint.cr @@ -55,12 +55,9 @@ module Flint parser.parse - if read_stdin - source_io = STDIN - elsif !source_file.nil? - # compilier complains without the not_nil! - source_io = File.new(source_file.not_nil!) - else + source_io = read_stdin ? STDIN : source_file.try { |f| File.new(f) } + + if source_io.nil? puts "ERROR: No source file chosen" puts parser exit(1) -- cgit v1.2.1