<iloveeveryfood>
test and test2 are only different in lines 4/5 and 22/23
rubydoc has quit [Ping timeout: 246 seconds]
rubydoc has joined #ruby
<nakilon>
Imagine there are class A and module B in Ruby stdlib, and I want to make class C < A that its instances first try to call the B methods with the same name and if it's a miss then call the inherited method of A
<nakilon>
I can either 1) use method_missing and such 2) declare all the 100-200 methods in my C 3) declare only a few and expand when requested by someone who wants to use my gem
<nakilon>
the case (1) will make the hell of inability to see method().source_location, you know; the (2) is just a lot of work that no one might use in future; the (3) -- people don't really want to use gems that have only one method no matter how much useful it is, they want to use gems that have megabytes of code in them
<nakilon>
which should I coose?
<nakilon>
*choose
Swyper has quit [Read error: Connection reset by peer]
Swyper has joined #ruby
<nakilon>
iloveeveryfood, the '{}' is a vector type of object -- the '=' operator copied not the whole object but only a reference to it; so both vars in result point to the same Hash, not two different ones
<iloveeveryfood>
My question got answered somewhere else. So, no explanation needed anymore. Thanks!
iloveeveryfood has quit [Remote host closed the connection]
<nakilon>
Hash and Array are vectors, Integer, True, False, Nil are scalars
rubydoc has quit [Ping timeout: 264 seconds]
<nakilon>
...
<apotheon>
iloveeveryfood: When you assign like `res= tmp= {}` you're actually assigning the same hash reference to both.
<apotheon>
err, damn
<apotheon>
I was just typing the response to that.
bairyn is now known as ByronJohnson
<apotheon>
Somehow, it got answered here *and* somewhere else while I was distracted by something someone said in meatspace.
rubydoc has joined #ruby
fandre1986 has quit [Quit: Connection closed]
Rudd0^ has joined #ruby
rubydoc_ has joined #ruby
rubydoc has quit [Remote host closed the connection]
Rudd0 has quit [Ping timeout: 260 seconds]
rubydoc_ has quit [Remote host closed the connection]
FastJack has quit [Ping timeout: 268 seconds]
FastJack has joined #ruby
rubydoc_ has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Kilo`byte has quit [Quit: ZNC - 1.6.0 - http://znc.in]
troulouliou_div2 has quit [Read error: Connection reset by peer]
chouhoulis has quit [Remote host closed the connection]
<splud>
I have an array with many rows, and multiple columns. each row defines a hardware part id, and some binary images associated with it. Thing is, some part ids (rows) have multiple combinations of images.
<splud>
I want to take those combinations and find all part ids that use them.
<apotheon>
-> example of pasting part of a file, in this case lines 21-30
gigetoo has quit [Ping timeout: 272 seconds]
<splud>
I don' paste example code so often <g>
<apotheon>
Of course, this sprunge script is only really useful if you're comfortable doing stuff like this at a terminal.
<splud>
I'm comfortable at a terminal, but this is made-up code to describe in simple terms a larger dataset which is very different. it's this basic relationship I'm trying to transform.
<splud>
amendment to the pastebin: Hash[ a.map {|k| ["#{k[1]} #{k[2]}", k]} ]
<splud>
basically gets me what I'd like, except for the 1:1 key:value resulting in the loss of the multiple values.
<splud>
I'm sorta looking for a hasharray like thing; key:array
<apotheon>
It looks like you want to #select where you have sub-arrays that #include? an arbitrary number of specified elements.
<splud>
hasharray being a made-up construct, though might intersect someones project name
<apotheon>
see the Array documentation I mentioned earlier for details about those methods.
<splud>
I'll go with 'yes' <g>
<apotheon>
Yes to what?
evdubs has quit [Quit: Leaving]
<splud>
sub-arrays include specified elements. Except that if I'm iterating at the time, I'm going to see the same pair of elements multiple times.
<apotheon>
I don't feel like you're really responding to what I said. Maybe I'm missing something.
<splud>
if I iterate over a, when I get to the third row, I have the same, lets' call it "key pair".
evdubs has joined #ruby
<apotheon>
At this point, I don't think we're communicating at all. I'll just leave this and move on, in case it helps:
<apotheon>
> a.select {|e| e.include? '100' and e.include? 'foo' }
<apotheon>
simplistic, limited use-case example of something that could be generalized with more code
<apotheon>
back to dealing with my domain transfers
<splud>
sorry, investigating the select inside a each loop of a, that was the nudge
<splud>
thank you.
<apotheon>
welcome
DTZUZU has quit [Read error: Connection reset by peer]
<splud>
an a.each do |ary| ... tmp = select { |e| ary[1] == e[1] and ary[2] == e[2] } ... is most of what I need.
<splud>
(obviously abbreviated here)
<splud>
the select is inside a conditional for whether the output hash already has the key, since if it does, that iteration of the pair has already been performed by an earlier occurrence.
fandre1986 has quit [Quit: Connection closed]
reaVer has quit [Quit: Lost terminal]
reaVer has joined #ruby
reaVer has quit [Client Quit]
reaVer has joined #ruby
TCZ has joined #ruby
roshanavand has quit [Quit: Quitting...]
ruurd has quit [Quit: ZZZzzz…]
ruurd has joined #ruby
axe has quit [Ping timeout: 264 seconds]
TCZ has quit [Quit: Leaving]
braincrash has quit [Ping timeout: 260 seconds]
_aeris has joined #ruby
_aeris_ has quit [Remote host closed the connection]