Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Ruby halp plx

Name: OP 2008-02-01 8:15

How do i make a key in a hash(in ruby, if you missed the subject) point to a key in another hash?

I want this:
hash1["key"] = "hay guise"
hash2["key"] = hash1["key"]
hash1["key"] = "ruby is for faggots"
p hash2["key"]

to output > "ruby is for faggots"

Name: Anonymous 2008-02-01 8:21

that's not a hash, that is a pointer

Name: Anonymous 2008-02-01 8:21

Your problem is not that you want to make a key in a hash point to a key in another hash, but something else. Tell us what that something else is and we will help you.

Name: Anonymous 2008-02-01 8:24

You can't.

Name: Anonymous 2008-02-01 8:30

>>3
The something else was an array, which i managed to solve now that you realized it for me, thanks.

Name: Anonymous 2008-02-01 9:11

FORCED HASHING OF KEYS

Name: Anonymous 2008-02-01 17:59

>>5

He means that you're using Ruby.

SET SAIL FOR FAIL

Name: Anonymous 2008-02-01 22:40

irb(main):001:0> h1={:key => "hay guise"}
=> {:key=>"hay guise"}
irb(main):002:0> h2={:key => h1[:key]}
=> {:key=>"hay guise"}
irb(main):003:0> h1[:key][0..-1] = "ruby is for faggots"
=> "ruby is for faggots"
irb(main):004:0> h1
=> {:key=>"ruby is for faggots"}
irb(main):005:0> h2
=> {:key=>"ruby is for faggots"}

Name: hujym27IB6 !wiAEQEbKZA 2009-02-18 11:17

>>1

Name: HzbiWThujc !K2HWohO.TI 2009-02-18 11:22

>>9

Name: Anonymous 2009-02-18 11:33

$j{key}='hey guise';
$k{key}=\$j{key};
$j{key}='ruby is for faggots';
print ${ $k{key} }

Name: Trollbot9000 2009-07-01 8:41

The point of thinking.

Name: Anonymous 2010-11-25 9:49

Don't change these.
Name: Email:
Entire Thread Thread List