diff --git a/Gemfile.lock b/Gemfile.lock index 21ef7d2..59b2f9c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - c66-copper (0.0.4) + c66-copper (0.0.5) colorize (~> 0.8) ipaddress (~> 0.8) json (~> 1.4) diff --git a/lib/copper/comparison.rb b/lib/copper/comparison.rb index af56032..d3f2efa 100644 --- a/lib/copper/comparison.rb +++ b/lib/copper/comparison.rb @@ -6,7 +6,8 @@ def value(vars = {}) comp_op = elements[1].value(vars) rhs = elements[2].value(vars) - raise ParseError, "cannot compare nil" if rhs.nil? || lhs.nil? + return true if rhs.nil? && lhs.nil? + return false if rhs.nil? || lhs.nil? puts "[DEBUG] Comparing #{lhs} (#{lhs.class.name}) #{comp_op} #{rhs} (#{rhs.class.name})" if $debug begin diff --git a/lib/copper/data_types/array.rb b/lib/copper/data_types/array.rb index d04a1df..76ebfeb 100644 --- a/lib/copper/data_types/array.rb +++ b/lib/copper/data_types/array.rb @@ -7,12 +7,12 @@ def count end def first - raise RuntimeError, "cannot call first on an empty array" if @value.empty? + return nil if @value.empty? return @value.first end def last - raise RuntimeError, "cannot call last on an empty array" if @value.empty? + return nil if @value.empty? return @value.last end diff --git a/lib/copper/version.rb b/lib/copper/version.rb index 2cb2b33..54162a7 100644 --- a/lib/copper/version.rb +++ b/lib/copper/version.rb @@ -1,5 +1,5 @@ module Copper - VERSION = '0.0.5' + VERSION = '0.0.6' COPYRIGHT_MESSAGE = "(c) 2018 Cloud66 Inc." APP_NAME = 'Copper' end