Create variables depending on counter

I think the decision “symbol or string” is not what you
should be concerned about right now, it’s a subtlety.
Both would work fine for you for the time being.

There are other problems:

Am 12.07.2013 09:23, schrieb stefan heinrich:

The values “a8”, “1e”, “98” etc. are random generated values. There are
not fixed but they have an interval. Depending on the value if the LSB =
1 it is an ON and LSB = 0 it is a OFF. So normally we can say without
looking to the syntax

def value_?even(value)
return :E_ON if value & 0x01
return :E_OFF
end

Have you actually tried that? It cannot work for a string `value’.

  1. You want numbers:

    “0a” & 1
    NoMethodError: undefined method `&’ for “0a”:String

    5 & 1

    => 1

    6 & 1

    => 0

  2. Your condition is always true:

    puts “true!” if 6 & 1

    true!

    (Note: in Ruby, 0 is true!)

So, do not get distracted by subtleties like symbols, but concentrate
on learning some Ruby basics and getting your program to work.

Regards,
Marcus