what's wrong? ` module resistorcolorduo cols = %w(black brown red orange yellow green blue violet grey white).map.with_index.to_h def self.value(input) = input.first(2).sum('', &cols).to_i end` in ruby

The code provided has a syntax error. In Ruby, you cannot assign a value inside a method definition using the = sign.

To fix the code, you can remove the equals sign after def self.value(input), and add an end keyword to close the method definition. Here's the corrected code:

main.rb
module ResistorColorDuo
  cols = %w(black brown red orange yellow green blue violet grey white).map.with_index.to_h

  def self.value(input)
    input.first(2).sum('', &cols).to_i
  end
end
190 chars
8 lines

Now the code should be valid.

related categories

gistlibby LogSnag