Commits

Anonymous committed 6a44d19

Convert the Cell constructor to a default argument.

And r2700!.

  • Participants
  • Parent commits aac788b

Comments (0)

Files changed (1)

hitori-solver-in-ruby/hitori-solver.rb

         attr_reader :state
         attr_reader :value
 
-        def initialize(val)
-            @state = UNKNOWN
-            if (val.class == Array) then
-                @value = val[0]
-                @state = val[1]
-            else
-                @value = val
-            end
+        def initialize(value, state = UNKNOWN)
+            @value, @state = value, state
         end
 
         # If the existing state is unknown, marks the cell as the new color
             for s_row in contents do
                 d_row = []
                 for v in s_row do
-                    d_row << Cell.new(v)
+                    d_row << Cell.new(*v)
                 end
                 if (d_row.length() != @x_len)
                     raise WrongRowLenException, \