znz_jp has quit [Remote host closed the connection]
znz_jp has joined #ruby
cuerbot has quit [Read error: Connection reset by peer]
elcuervo has joined #ruby
dfucci has quit [Ping timeout: 256 seconds]
cowgomoo has quit [Remote host closed the connection]
prion has joined #ruby
Swyper has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 260 seconds]
Emmanuel_Chanel has joined #ruby
banisterfiend has quit [Read error: Connection reset by peer]
apotheon has quit [Ping timeout: 240 seconds]
apotheon has joined #ruby
adu has joined #ruby
greenbagels has quit [Quit: WeeChat 2.3]
pinkpandabot has quit [Quit: new aoc session...]
dfucci has joined #ruby
dfucci has quit [Ping timeout: 258 seconds]
SaintNickname has joined #ruby
pwnd_sfw5 has joined #ruby
pwnd_sfw has quit [Ping timeout: 256 seconds]
pwnd_sfw5 is now known as pwnd_sfw
adu has quit [Quit: adu]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
blackmesa1 has joined #ruby
cd has quit [Quit: cd]
Swyper has joined #ruby
Swyper has quit [Ping timeout: 260 seconds]
SaintNickname has quit [Remote host closed the connection]
<KrzaQ>
Is there a way to format a #{} interpolated string? E.g. I'd want something like "Foo: #{.3f:1.0/3}" to display 'Foo: 0.33'
blackmesa1 has quit [Ping timeout: 260 seconds]
blackmesa1 has joined #ruby
akem__ has joined #ruby
akem_ has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has joined #ruby
dfucci has joined #ruby
mozzarella has quit [Ping timeout: 240 seconds]
dfucci has quit [Ping timeout: 240 seconds]
<apotheon>
KrzaQ: "Foo: #{ "%.3f" % (1.0 / 3) }"
akem__ is now known as Chew
Chew is now known as Cheww
<KrzaQ>
At this point I can use % directly. But thanks. I wasn't even sure how to google that question
<leftylink>
cd hmm
<leftylink>
"formatting in ruby string interpolation" or something
<KrzaQ>
yeah, that returned a bunch of results for Kernel::sprintf/%
<apotheon>
KrzaQ: Don't forget "format" as well as "sprintf" and "%".
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
braincrash has joined #ruby
naftilos76 has joined #ruby
<naftilos76>
Hi every one. I am trying to use the queue class inside ruby threads. It seems to work fine until all threads reach the point where queue.length equals zero and then i get "No live threads left. Deadlock?"
lucidreamachine has quit [Remote host closed the connection]
lucidreamachine has joined #ruby
<naftilos76>
Could it be that i simply have to set some kind of property of the Thread class in order to allow threads blocked for ever?
al2o3-cr has joined #ruby
<naftilos76>
until the next task is added to the queue off course
<leftylink>
hmm... well, certainly the output is telling the truth - there are no more live threads, because of the join. wouldn't a more accurate test be to have to main thread sleep for a number of seconds, then push another batch of tasks in?
<leftylink>
and then sleep again
<leftylink>
or I guess after the second batch of tasks then `join` is "fine" as in it'll not wait too long but still demonstrate that the threads were woken up
<leftylink>
the comment on line 25 is wrong
<leftylink>
join is not needed to execute the threads
dfucci has joined #ruby
<naftilos76>
leftylink: i intentionally put those comments just in case i have the wrong idea. Then why is join used after all?
<leftylink>
join is used when you need to wait for the thread to exit. for example, if you absolutely cannot proceed without the thread having completed. note that in this case it doesn't make sense to `join` on those threads, since they *never* exit
<naftilos76>
so your telling me that i do not need to join those threads at all?
dfucci has quit [Ping timeout: 256 seconds]
<leftylink>
well, why do people join threads at all. if one runs `ruby -e "Thread.new { puts :yes }"`, one will likely never see any output at all, because the program exits before the thread prints yes
<naftilos76>
i just commented the join expression and all i go was "Thread id: 0, tasks waiting: 0" and the process exited
<naftilos76>
it is clear that i do not have a solid understanding of what is going on here
<leftylink>
for the same reason as why `ruby -e "Thread.new { puts :yes }"` prints nothing
<leftylink>
program exits before thread prints
<naftilos76>
ok thanks for your time
weaksauce has quit [Ping timeout: 258 seconds]
evdubs_ is now known as evdubs
drincruz has joined #ruby
vondruch has quit [Read error: Connection reset by peer]
aremaref has joined #ruby
drincruz has quit [Ping timeout: 264 seconds]
aremaref has quit [Ping timeout: 246 seconds]
hiroaki has joined #ruby
dfucci has joined #ruby
tfk has joined #ruby
iNs has quit [Ping timeout: 240 seconds]
Cheww has quit [Ping timeout: 240 seconds]
iNs has joined #ruby
blackmesa1 has quit [Ping timeout: 265 seconds]
Technodrome has joined #ruby
tfk has quit [Quit: tfk]
w0rstpr0grammer_ has joined #ruby
w0rstpr0grammer_ has quit [Quit: w0rstpr0grammer_]
blackmesa1 has joined #ruby
blackmesa1 has quit [Ping timeout: 264 seconds]
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
Xiti has quit [Read error: Connection reset by peer]
Xiti has joined #ruby
akem has joined #ruby
akem_ has joined #ruby
akem has quit [Ping timeout: 256 seconds]
w0rstpr0grammer_ has joined #ruby
w0rstpr0grammer_ is now known as w0rstpr0grammer
somazero has joined #ruby
somazero has quit [Remote host closed the connection]
batisi[m] has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
w0rstpr0grammer has quit [Quit: w0rstpr0grammer]
w0rstpr0grammer has joined #ruby
w0rstpr0grammer has quit [Quit: w0rstpr0grammer]
w0rstpr0grammer has joined #ruby
BSaboia has joined #ruby
Swyper has joined #ruby
* nakilon
woke up
<nakilon>
>> ["abc", "10"].map{ |i| Integer i rescue i }
somazero has quit [Remote host closed the connection]
dfucci has quit [Ping timeout: 240 seconds]
mcspud has quit [Ping timeout: 272 seconds]
blackmesa has joined #ruby
blackmesa1 has joined #ruby
blackmesa has quit [Ping timeout: 260 seconds]
blackmesa1 has quit [Ping timeout: 265 seconds]
mcspud has joined #ruby
dfucci has joined #ruby
blackmesa1 has joined #ruby
dfucci has quit [Ping timeout: 256 seconds]
jinie has quit [Ping timeout: 260 seconds]
dfucci has joined #ruby
jinie has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
adu has quit [Quit: adu]
braincrash has quit [Ping timeout: 272 seconds]
Caerus has quit [Ping timeout: 260 seconds]
Caerus has joined #ruby
jinie has quit [Ping timeout: 272 seconds]
dfucci has joined #ruby
blackmesa1 has quit [Ping timeout: 260 seconds]
orbyt_ has joined #ruby
Caerus has quit [Ping timeout: 246 seconds]
jinie has joined #ruby
dfucci has quit [Ping timeout: 240 seconds]
blackmesa1 has joined #ruby
braincrash has joined #ruby
drincruz has joined #ruby
blackmesa1 has quit [Ping timeout: 264 seconds]
Rudd0 has quit [Read error: Connection reset by peer]
Caerus has joined #ruby
blackmesa1 has joined #ruby
braincrash has quit [Ping timeout: 240 seconds]
blackmesa1 has quit [Ping timeout: 260 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZU has joined #ruby
TCZ has joined #ruby
dfucci has joined #ruby
ur5us has joined #ruby
aremaref has joined #ruby
hiroaki has joined #ruby
braincrash has joined #ruby
<tempate>
Hello. How can I remove an element from an array at a certain index and get the array itself as the return type, instead of the element I just deleted?
<rubydoc__>
stderr: -e:4:in `block in <main>': undefined local variable or method `i' for main:Object (NameError)... check link for more (https://carc.in/#/r/a3wk)
<leftylink>
I sorta respect that, but if they're going to be multiplied and one factor shouldn't be multiplied, I also suggest multiplying them all and mapping over it via division of individual elements
<tempate>
Yeah, that's another way to go about it, sure
<tempate>
I thought I may be missing out on something fancier
<leftylink>
Ruby 3.0 gets Hash#except, though I don't think there's Array#except yet...
<tempate>
Is there a way for me to multiply all the :ids together or do I have to use a map?
naftilos76 has quit [Ping timeout: 264 seconds]
<leftylink>
no, if this were a sum then it'd be possible to use buses.sum { |bus| bus[:id] }, but no such convenience for product
<leftylink>
actually... I think sum takes some arguments? let me investigate...
<tempate>
It seems like the most readable option to me
<leftylink>
if performance was really important, I would really stress that that entire term, `schedules.map{ |schedule| schedule[:id] }.inject(:*) `, should be pulled out and computed once only
<leftylink>
but it doesn't matter for the input size given so whatever
<leftylink>
but I still suggest it on principle.
<tempate>
leftylink: oh, yeah, right...
<leftylink>
as you can see, it doesn't depend on i
<leftylink>
indeed
<tempate>
I'll do it, why not
<tempate>
Is there a difference between .inject(&:*) and .inject(:*) ?
aremaref has quit [Ping timeout: 240 seconds]
<havenwood>
tempate: Same functionality.
<havenwood>
tempate: many folk these days would use the alias: reduce(:*)
<havenwood>
tempate: It's cheap to `map(&:to_i)` in a small collection or a local variable inside the block would do the trick.
<tempate>
havenwood: yeah, I liked that. I'm going for it.
<tempate>
Once again, just to be clear, this: schedules.map{ |schedule| schedule[:id] }, can't be simplified, right?
<leftylink>
I wish it could. if it were a struct instead, then schedules.map(&:id). but it's not a struct it's a hash. and no Ruby 2.7 means no schedules.map { _1[:id] }
blackmesa1 has joined #ruby
duderonomy has joined #ruby
blackmesa1 has quit [Ping timeout: 258 seconds]
aremaref has quit [Ping timeout: 256 seconds]
<tempate>
sad
<havenwood>
leftylink: tempate: but in those earlier Rubies you can: schedules.map { |id:| id }
<rubydoc__>
# => ["true and true"] stderr: -e:4: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call... check link for more (https://carc.in/#/r/a3x8)
<havenwood>
(No warning pre-2.7.)
Rudd0 has joined #ruby
<leftylink>
hmm. I would maybe have considered using that, but I guess if it's a warning then no
<havenwood>
leftylink: Only a warning approaching 3.0.
<havenwood>
leftylink: Pre-2.7 it's fine.
<havenwood>
leftylink: But yeah, not future-looking good.
<havenwood>
leftylink: Well, we'll see.
<tempate>
I'm running 2.5 now but I'm not sure how I feel about using deprecated stuff
<havenwood>
leftylink: Kwargs are a very late decision for 3.0.
<havenwood>
tempate: We'll know within a few weeks if that deprecation warning is sticking.
<tempate>
havenwood: what version is coming out?
<havenwood>
tempate: 3.0 on Christmas.
<havenwood>
tempate: Major update! :)
blackmesa1 has joined #ruby
<havenwood>
tempate: Less than two weeks, and Ruby 3.0 is out.
<nakilon>
not quite sure what's the purpose... is it for compatibility between OSs?
TCZ has quit [Quit: P?o lesie przechadza sie zamyslony Zygfryd]
prion has quit [Ping timeout: 240 seconds]
<havenwood>
nakilon: yup, just that
<nakilon>
httpd is a handy thing -- I used it to test port forwarding
braincra- has quit [Ping timeout: 256 seconds]
<nakilon>
it didn't need all the abilities of webrick though, just respond anything when I open a link in browser or curl
<tempate>
havenwood: oh, nice!
prion has joined #ruby
<tempate>
havenwood: before you said .map(&:to_i) is quite cheap; why is that?
Technodrome has joined #ruby
dfucci has joined #ruby
blackmesa has joined #ruby
blackmesa1 has quit [Ping timeout: 260 seconds]
TCZ has joined #ruby
TCZ has quit [Client Quit]
TCZ has joined #ruby
thecoffemaker has quit [Ping timeout: 240 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
prion has quit [Ping timeout: 260 seconds]
dfucci has quit [Ping timeout: 256 seconds]
thecoffemaker has joined #ruby
weaksauce has joined #ruby
gdonald has joined #ruby
joast has quit [Quit: Leaving.]
joast has joined #ruby
blackmesa has quit [Ping timeout: 258 seconds]
<havenwood>
tempate: The &:to_i parses a bit faster than a full block variant, so two of them can be faster than one full block (in this case, there's a full block subsequently, so not faster). A #to_i is fast, so with small collections the whole thing is kinda hand wavey quick. Benchmarks also vary by Ruby implementation. My main point is that the relative expense of either way is quite small with extremely quick methods like this one on anything that's not