From: Robert Klemme Date: 2013-07-11T00:20:03+09:00 Subject: Re: create variables depending on counter --001a11c2b80ebd2bc004e129cf34 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jul 10, 2013 at 4:21 PM, stefan heinrich wrote: > Hi Robert and Marcus, > > thanks for your help. Both methods are working very fine :D. > But now I have the Problem that I couldn't combine the values. > > The Result of my script looks like: > > => {"I OFF"=>["34"], "E OFF"=>["92", "94"], "E ON"=>["7f"], > "I ON"=>["d9", "cf"]} > Why are the elements in the arrays not numbers? It looks like you rather want to work with numbers (Fixnum) here. I get always a nil when I want combine each value from one Array with > the other values from the other Arrays. I use > > data.first.product(*data[1..-1]).map(&:join) > > Can u say what the problem is now? > Can you show us what's in data? Please make sure to present complete examples, otherwise it's difficult to come up with answers - and to follow the discussion as well. > And if its possible can you explain how I can only combine I with E > values. > It doesnt make sense if I combine "I ON" with "I OFF" or "E ON" with "E > OFF". > Well, just select e.g. irb(main):001:0> h = {"I OFF"=>["34"], "E OFF"=>["92", "94"], "E ON"=>["7f"], "I ON"=>["d9", "cf"]} => {"I OFF"=>["34"], "E OFF"=>["92", "94"], "E ON"=>["7f"], "I ON"=>["d9", "cf"]} irb(main):002:0> h.select {|k,| /^I/ =~ k} => {"I OFF"=>["34"], "I ON"=>["d9", "cf"]} irb(main):003:0> h.select {|k,| /^E/ =~ k} => {"E OFF"=>["92", "94"], "E ON"=>["7f"]} Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ --001a11c2b80ebd2bc004e129cf34 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable



On Wed, Jul 10, 2013 at 4:21 PM, stefan heinrich = <lists@ruby-fo= rum.com> wrote:
Hi Robert and Marcus,

thanks for your help. Both methods are working very fine :D.
But now I have the Problem that I couldn't combine the values.

The Result of my script looks like:

=3D> {"I OFF"=3D>["34"], "E OFF"=3D>= ["92", "94"], "E ON"=3D>["7f"],<= br> =A0 =A0 "I ON"=3D>["d9", "cf"]}

Why are the elements in the arrays not numbers? = =A0It looks like you rather want to work with numbers (Fixnum) here.=A0

I get always a nil when I want combine each value from one Array with
the other values from the other Arrays. I use

=A0data.first.product(*data[1..-1]).map(&:join)

Can u say what the problem is now?

Can = you show us what's in data? =A0Please make sure to present complete exa= mples, otherwise it's difficult to come up with answers - and to follow= the discussion as well.
=A0
And if its possible can you explain how I ca= n only combine I with E
values.
It doesnt make sense if I combine "I ON" with "I OFF" o= r "E ON" with "E
OFF".

Well, just select e.g.
=

irb(main):001:0> h =3D {"I OFF"=3D>= ;["34"], "E OFF"=3D>["92", "94"]= , "E ON"=3D>["7f"], "I ON"=3D>["d9= ", "cf"]}
=3D> {"I OFF"=3D>["34"], "E OFF"= =3D>["92", "94"], "E ON"=3D>["7f&q= uot;], "I ON"=3D>["d9", "cf"]}
i= rb(main):002:0> h.select {|k,| /^I/ =3D~ k}
=3D> {"I OFF"=3D>["34"], "I ON"=3D= >["d9", "cf"]}
irb(main):003:0> h.selec= t {|k,| /^E/ =3D~ k}
=3D> {"E OFF"=3D>["92&q= uot;, "94"], "E ON"=3D>["7f"]}

Kind regards

robert

--
remember.guy do |as, often| as.you_ca= n - without end
http://blog.rubybestpractice= s.com/
--001a11c2b80ebd2bc004e129cf34--