#ruby-lang - Tue 3 Apr 2007 between 14:45 and 14:52

NY Lost Funds



dcnstrctguys how do I turn a string "true" into a bool ?
or "false" for that matter
apeiros"true" == "true"
rretzbach{'true' => true, 'false' => false} ?
dcnstrctah right
apeirosand if it can be only either of the two: string == "true"
rretzbachOr use eval.
apeiroswill be false for false
actionapeiros throws rretzbach to the lobster as food
apeirosthrows rretzbach to the lobster as food
dcnstrctI was thinking they'd be some to_bool method, but your right there is no need
rretzbachapeiros: I just don't like to "hack"
notjohnstr == true' ? True : f
rretzbachseeing a conditional like foo == "true" ist just wrong :\
notjohnstr == 'true' ? True : False is what i meant
bkudriahow do i puts somethign to stderr instead of stdout?
notjohni'm still confused with hash indexes using symbols vs strings
kesVbkudria: use $stderr.puts
rretzbachwell symbols are much cooler :>
dasil003notjohn: they are different. It's only Rails that makes them the same by using HashWithIndifferentAccess
apeirosrretzbach, ah, but eval(string) is not hacky?
geez
rretzbachbla :>
bkudriakesV: thanks
rretzbachIt was my alternative.
notjohndasil003: that's what i thought
but does it have something to do with how a hash is declared?
kesVno
dasil003do some experiments in script/console
kesVa Symbol is just another kind of object to use as key, just like a Fixnum or String
lypanovapeiros: i love logic :)
notjohni'll agree that : symbols look cooler....but I'd like to know when you can or should use either
lypanovbbl
dasil003notjohn: I don't think it really matters. But if you are not going to print the key, then a symbol is marginally more efficient as far as I know.
kesVnotjohn: there is only one reason to use a symbol. Symbols are atomic. i.e. they exist only once in the Symbol lookup table, so no matter how many times they are used, they take the same amount of memory
Silowyi[[1,2,3],[4,5,6]] any way to easily get from there to [1,2,3,4,5,6]?
notjohnSilowyi: i think there's a flatten method
dasil003array.flatten
Silowyithanks
kesVnotjohn: however there is a limit on the size of the symbol table. if you need millions of keys, it's better to use strings
rretzbachCan two different symbols have the same hash value?

Page: 2 9 16 23 30 37 44 51 58 65 72 

IrcArchive

NY Lost Funds