<dminuoso>
leitz: Pretty sure you are not getting the same error.
<dminuoso>
leitz: Im pretty this time it's "No such method `age' for 12:Integer"
<dminuoso>
leitz: The problem is not the puts.
<dminuoso>
leitz: The problem is that you are reassigning in 7.
<dminuoso>
Dont assign to @char.
dionysus69 has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 268 seconds]
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drewmcmillan has joined #ruby
desperek has joined #ruby
* leitz
, back from making breakfast for the dogs, notes that dminuso is correct on the error.
gary has joined #ruby
gary is now known as Guest89075
<leitz>
dminuso, design question. The goal is to have a Factory that modifies an instance of Character. There will be different Careers in the Factory. Should the Character generation even be in the Factory?
Guest89075 has quit [Ping timeout: 264 seconds]
willmichael has quit [Ping timeout: 256 seconds]
willmichael has joined #ruby
* leitz
needs to learn to spell names, like dminuoso...
someuser has quit [Ping timeout: 264 seconds]
alfiemax has joined #ruby
milardovich has quit []
Xiti` has joined #ruby
AX31_A13X has joined #ruby
shortdudey123 has quit [Ping timeout: 264 seconds]
despai has quit [Quit: ...]
alfiemax has quit [Ping timeout: 240 seconds]
shortdudey123 has joined #ruby
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 264 seconds]
AJA4351 is now known as AJA4350
AxelAlex has quit [Ping timeout: 264 seconds]
Xiti has quit [Ping timeout: 264 seconds]
despai has joined #ruby
X-Jester_ has joined #ruby
despai has quit [Client Quit]
WhereIsMySpoon has joined #ruby
WhereIsMySpoon has quit [Changing host]
WhereIsMySpoon has joined #ruby
flak has joined #ruby
cschnei__ has joined #ruby
bl4ckn1nj4 has joined #ruby
Greasy-Gappers_ has joined #ruby
ghormoon_ has joined #ruby
jpterry_ has joined #ruby
hinbody_ has joined #ruby
raddazong has joined #ruby
reaVer_ has joined #ruby
kliq has quit [Ping timeout: 252 seconds]
r3m_ has joined #ruby
konsolebox_ has joined #ruby
_derpy has joined #ruby
eam_ has joined #ruby
WhereIsMySpoon_ has quit [Ping timeout: 264 seconds]
X-Jester has quit [Ping timeout: 264 seconds]
shinnya has quit [Ping timeout: 240 seconds]
JoshL- has joined #ruby
nielsk_ has joined #ruby
_musl_ has joined #ruby
MochaLoca has joined #ruby
kn1ght has joined #ruby
Xiti` has quit [Ping timeout: 264 seconds]
tcopeland has quit [Ping timeout: 264 seconds]
eckhardt has quit [Ping timeout: 264 seconds]
jpterry has quit [Ping timeout: 264 seconds]
ghormoon has quit [Ping timeout: 264 seconds]
nielsk has quit [Ping timeout: 264 seconds]
garyserj has quit [Ping timeout: 264 seconds]
konsolebox has quit [Ping timeout: 264 seconds]
jpterry_ is now known as jpterry
cschneid has quit [Ping timeout: 264 seconds]
qyliss_ has quit [Ping timeout: 264 seconds]
`derpy has quit [Ping timeout: 264 seconds]
hinbody has quit [Ping timeout: 264 seconds]
JoshL has quit [Ping timeout: 264 seconds]
garyserj has joined #ruby
madhatter has quit [Ping timeout: 264 seconds]
Greasy-Gappers has quit [Ping timeout: 264 seconds]
rippa has quit [Ping timeout: 264 seconds]
reaVer has quit [Ping timeout: 264 seconds]
LocaMocha has quit [Ping timeout: 264 seconds]
musl_ has quit [Ping timeout: 264 seconds]
ricer2 has quit [Ping timeout: 264 seconds]
eldritch has quit [Ping timeout: 264 seconds]
fumck has quit [Ping timeout: 264 seconds]
r3m has quit [Ping timeout: 264 seconds]
eam has quit [Ping timeout: 264 seconds]
S007 has quit [Ping timeout: 264 seconds]
knight- has quit [Ping timeout: 264 seconds]
fumk has joined #ruby
qyliss_ has joined #ruby
jamesaxl has quit [Read error: Connection reset by peer]
jamesaxl has joined #ruby
r3m_ is now known as r3m
S007 has joined #ruby
eldritch has joined #ruby
dinfuehr has quit [Ping timeout: 260 seconds]
someuser has joined #ruby
dinfuehr has joined #ruby
mikecmpbll has joined #ruby
gary_ has joined #ruby
gary_ is now known as Guest72017
eldritch2 has joined #ruby
eldritch has quit [Ping timeout: 264 seconds]
someuser has quit [Ping timeout: 252 seconds]
mikecmpbll has quit [Client Quit]
eldritch2 is now known as eldritch
quobo has quit [Quit: Connection closed for inactivity]
n008f4g_ has joined #ruby
Guest40768 has quit [Changing host]
Guest40768 has joined #ruby
Guest40768 has joined #ruby
Guest40768 is now known as pskosinski
Guest72017 has quit [Ping timeout: 260 seconds]
agit0 has joined #ruby
dionysus69 has quit [Ping timeout: 248 seconds]
mtkd has quit []
jaruga has joined #ruby
fumck has joined #ruby
Lyubo1 has quit [Ping timeout: 264 seconds]
fumk has quit [Ping timeout: 264 seconds]
^mtkd has joined #ruby
mikecmpbll has joined #ruby
goatish has quit [Quit: Hibernating]
mikecmpbll has quit [Client Quit]
alfiemax has joined #ruby
za1b1tsu has joined #ruby
alfiemax has quit [Ping timeout: 252 seconds]
snickers has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drewmcmillan has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dmitriy_ has quit [Read error: Connection reset by peer]
bigblind has quit [Ping timeout: 256 seconds]
cabotto has quit [Ping timeout: 245 seconds]
rikkipitt has joined #ruby
rikkipitt has quit [Remote host closed the connection]
harmaahylje has quit [Ping timeout: 240 seconds]
cabotto has joined #ruby
willmichael has quit [Ping timeout: 256 seconds]
willmichael has joined #ruby
za1b1tsu has quit [Quit: Leaving]
harmaahylje has joined #ruby
cabotto has quit [Ping timeout: 240 seconds]
bigblind has joined #ruby
c0dec_ has joined #ruby
cabotto has joined #ruby
Emmanuel_Chanel has joined #ruby
harmaahylje has quit [Ping timeout: 240 seconds]
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
harmaahylje has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 240 seconds]
gary has joined #ruby
gary is now known as Guest99088
cabotto has quit [Ping timeout: 240 seconds]
Guest99088 has quit [Ping timeout: 245 seconds]
Sembei has quit [Ping timeout: 240 seconds]
harmaahylje has quit [Ping timeout: 252 seconds]
MyMind has joined #ruby
cabotto has joined #ruby
devil_tux has quit [Ping timeout: 252 seconds]
harmaahylje has joined #ruby
cabotto has quit [Ping timeout: 245 seconds]
cabotto has joined #ruby
gary_ has joined #ruby
gary_ is now known as Guest23312
karapetyan has quit [Remote host closed the connection]
herbmillerjr has quit [Quit: Konversation terminated!]
cabotto has quit [Ping timeout: 252 seconds]
shortdudey123 has quit [Ping timeout: 248 seconds]
amelliaa has joined #ruby
jerikl has joined #ruby
darkhanb has joined #ruby
cabotto has joined #ruby
Guest23312 has quit [Ping timeout: 240 seconds]
minimalism has joined #ruby
gary__ has joined #ruby
harmaahylje has quit [Ping timeout: 248 seconds]
Emmanuel_Chanel has joined #ruby
shortdudey123 has joined #ruby
Emmanuel_Chanel has quit [Remote host closed the connection]
Emmanuel_Chanel has joined #ruby
darkhanb has quit [Ping timeout: 245 seconds]
harmaahylje has joined #ruby
gary__ has quit [Ping timeout: 245 seconds]
gary__ has joined #ruby
orbyt_ has joined #ruby
karapetyan has joined #ruby
harmaahylje has quit [Ping timeout: 256 seconds]
willmichael has quit [Read error: Connection reset by peer]
cabotto has quit [Ping timeout: 240 seconds]
cabotto has joined #ruby
willmichael has joined #ruby
gary__ has quit [Ping timeout: 252 seconds]
gary has joined #ruby
gary is now known as Guest60121
anisha_ has quit [Quit: This computer has gone to sleep]
anisha_ has joined #ruby
cabotto has quit [Ping timeout: 252 seconds]
anisha_ has quit [Client Quit]
harmaahylje has joined #ruby
Guest60121 has quit [Ping timeout: 245 seconds]
cabotto has joined #ruby
Xiti has joined #ruby
gary_ has joined #ruby
gary_ is now known as Guest8822
harmaahylje has quit [Ping timeout: 260 seconds]
harmaahylje has joined #ruby
workmad3 has joined #ruby
funnel has quit [Ping timeout: 256 seconds]
milardovich has joined #ruby
someuser has joined #ruby
funnel has joined #ruby
dinfuehr has quit [Ping timeout: 240 seconds]
workmad3 has quit [Ping timeout: 256 seconds]
raynold has joined #ruby
dinfuehr has joined #ruby
Guest8822 has quit [Ping timeout: 256 seconds]
gary__ has joined #ruby
cabotto has quit [Ping timeout: 256 seconds]
harmaahylje has quit [Ping timeout: 240 seconds]
sammi` has quit [Quit: leaving]
harmaahylje has joined #ruby
cabotto has joined #ruby
schneide1 has joined #ruby
gary__ has quit [Ping timeout: 252 seconds]
gary__ has joined #ruby
harmaahylje has quit [Ping timeout: 245 seconds]
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
claudiuinberlin has joined #ruby
cabotto has quit [Ping timeout: 252 seconds]
gothicsouth has joined #ruby
sammi` has joined #ruby
cabotto has joined #ruby
despai has joined #ruby
despai has quit [Client Quit]
gothicsouth has quit [Client Quit]
DoubleMalt has joined #ruby
AX31_A13X has quit [Quit: AX31_A13X]
gothicsouth has joined #ruby
DoubleMalt has quit [Remote host closed the connection]
jerikl has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gothicsouth has quit [Client Quit]
jerikl has joined #ruby
clemens3 has joined #ruby
shinnya has joined #ruby
harmaahylje has joined #ruby
cabotto has quit [Ping timeout: 245 seconds]
harmaahylje has quit [Client Quit]
harmaahylje has joined #ruby
bigblind has quit [Ping timeout: 240 seconds]
cabotto has joined #ruby
stormpack has quit [Quit: Leaving]
karapetyan has quit [Remote host closed the connection]
karapetyan has joined #ruby
cabotto has quit [Ping timeout: 240 seconds]
jerikl has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pocketprotector has quit [Ping timeout: 276 seconds]
cabotto has joined #ruby
gary__ has quit [Ping timeout: 245 seconds]
gary__ has joined #ruby
gary__ has quit [Ping timeout: 248 seconds]
gary has joined #ruby
karapetyan has quit [Remote host closed the connection]
gary is now known as Guest19152
schneide1 has quit [Quit: leaving]
DoubleMalt has joined #ruby
DoubleMalt has quit [Client Quit]
schneide1 has joined #ruby
Guest19152 has quit [Ping timeout: 252 seconds]
<Mike11>
I have a large sorted array of numbers (in ascending order). How can I find the last element in that array that is smaller than a given number x?
tcopeland has joined #ruby
<Mike11>
I am currently doing something like this:
<Mike11>
sorted_array.select { |i| i < x } .last
<Mike11>
it works, but it doesn't seem that it is best way to me, as it doesn't take advantage of the fact that the array is sorted
MyMind has quit [Read error: Connection reset by peer]
MyMind has joined #ruby
Guest80919 has quit [Ping timeout: 252 seconds]
cabotto has joined #ruby
karapetyan has joined #ruby
baweaver is now known as baweaver_away
cabotto has quit [Ping timeout: 245 seconds]
cabotto has joined #ruby
baweaver_away is now known as baweaver
tomphp has joined #ruby
karapetyan has quit [Remote host closed the connection]
tomphp has quit [Client Quit]
cabotto has quit [Ping timeout: 240 seconds]
karapetyan has joined #ruby
cabotto has joined #ruby
alfiemax_ has quit [Remote host closed the connection]
<Mike11>
so, in a sorted array (in ascending order), I wanted to find the last element that is smaller than a given number. bsearch was really helpful, but applying it directly gives the first element that is larger than a given number (i.e. I am seeking the preceding element to that)
karapetyan has quit [Remote host closed the connection]
karapetyan has joined #ruby
<Mike11>
I ended up doing something like this:
<Mike11>
sorted_array.each_with_index.to_a.reverse.bsearch { |n, i| n < some_number }
bigblind has joined #ruby
tomphp has joined #ruby
<Mike11>
this seems to give me what I want. but I am worried again about efficiency, since I am creating another array by reversing this array. is there a better way, or is this solution okay?
cabotto has quit [Ping timeout: 240 seconds]
jordanm has quit [Quit: Konversation terminated!]
gary__ has joined #ruby
cabotto has joined #ruby
alfiemax has joined #ruby
alfiemax has quit [Remote host closed the connection]
rrutkowski has joined #ruby
darkhanb_ has joined #ruby
gary__ has quit [Ping timeout: 240 seconds]
phaul has joined #ruby
schneide1 has quit [Quit: leaving]
jordanm has joined #ruby
darkhanb has quit [Ping timeout: 256 seconds]
cabotto has quit [Ping timeout: 248 seconds]
guardianx has joined #ruby
cabotto has joined #ruby
quobo has quit [Quit: Connection closed for inactivity]
bigblind has quit [Ping timeout: 256 seconds]
kromm has joined #ruby
kromm has left #ruby [#ruby]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gary has joined #ruby
alfiemax has joined #ruby
gary is now known as Guest41907
cabotto has quit [Ping timeout: 256 seconds]
MyMind has quit [Read error: Connection reset by peer]
MyMind has joined #ruby
dmitriy_ has joined #ruby
dmitriy_ has quit [Read error: Connection reset by peer]
<weaksauce>
for small arrays that's fine
Guest41907 has quit [Ping timeout: 256 seconds]
biberu has quit []
<Mike11>
weaksauce: my array might have 10k elements, is that considered fine or not?
<weaksauce>
Mike11 what's your definition of performant? how often are you doing this? how large are the objects?
<weaksauce>
how much ram does your server have?
<Mike11>
well, basically, I just want to get it as fast as possible
cabotto has joined #ruby
<Mike11>
it works for me that way it is now, but I just wanted to make sure I am not missing an obvious optimization technique
<weaksauce>
though bsearch doesn't actually work the way you are using it
<weaksauce>
try some_number - n instead of n < somenumber