Hello everybody i am a new ruby user and i learn best by doing. so i am
trying to code what i would imagine to be a better tool tracjing system
for y work. right now i am trying to figure out how to get a number to
pull up a name. The various way's i have tried to do this is:
44523 = "andrew lee"
44523.to_s. = "andrew lee"
44523.to_s. {"arg1 = "andrew lee"}
I would really like some help im sure this is a simply done but i cant
figure it out thanks for your help.
on 2013-03-06 21:04
on 2013-03-06 21:10
Is there another language where you could do something like this?
You can use a hash if you want something similar
irb(main):019:0> my_hash = { 44523 => "andrew lee" }
=> {44523=>"andrew lee"}
irb(main):020:0> my_hash[44523]
=> "andrew lee"
on 2013-03-07 03:06
On Wed, Mar 6, 2013 at 2:04 PM, Andrew l. <lists@ruby-forum.com> wrote:
> figure it out thanks for your help.
No language I'm currently familiar with allows you to assign one
literal to another.
44523 is not a variable, it is a literal FixNum in Ruby, and a literal
of some kind of integer in other languages.
on 2013-03-07 07:45
So you cannot convert 44523 or any other umber into an array or hash or anything that changes that value into something that can have something assigned to it?
on 2013-03-07 07:58
Subject: Re: Numbers and groups. Date: gio 07 mar 13 03:45:56 +0900 Quoting Andrew l. (lists@ruby-forum.com): > So you cannot convert 44523 or any other umber into an array or hash or > anything that changes that value into something that can have something > assigned to it? Of course you can use an integer as a key to a hash: irb(main):001:0> h={} => {} irb(main):002:0> h[44523]='a string' => "a string" irb(main):003:0> h[71234]='another string' => "another string" irb(main):004:0> h => {44523=>"a string", 71234=>"another string"} irb(main):005:0> h[44523] => "a string" Carlo
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.