<klf>
nvm, it appears that it's simply part of the method name
<llua>
indeed
<llua>
its a convention where the method modifies the object itself instead of returning a new object
<klf>
A small follow-up to q1): In our example above, the block is a do-block, and the block argument is 's', denoted using the |s| notation.
<klf>
so if the block accepts mulitple arguments, then are they specified as a comma separated list?
<klf>
e.g. |a|,|b|,|c|
<llua>
|a, b, c|
<klf>
llua, great. It might be time to pick up the Ruby langauge as I find myself needing to tinker with homebrew. (TLDR; since I am still on a 2011 MBP runnning 10.15.7 and that the homebrew maintainers peeve at those running unsupported versions; Okay, I'll stop ranting now)
Pixi` has quit [Quit: Leaving]
klf has quit [Quit: Leaving]
Pixi has joined #ruby
klf has joined #ruby
klf has quit [Quit: Leaving]
sarna has quit [Remote host closed the connection]
sarna has joined #ruby
chen has quit [Ping timeout: 252 seconds]
Linux_Kerio has quit [Ping timeout: 252 seconds]
BSaboia has joined #ruby
grenierm has quit [Ping timeout: 256 seconds]
Artea has joined #ruby
Pixi` has joined #ruby
SaveFerris3 has joined #ruby
Quiet-Oil92622 has joined #ruby
meimei_ has joined #ruby
brw9 has joined #ruby
pounce_ has joined #ruby
caleb__ has joined #ruby
llua` has joined #ruby
Rounin has joined #ruby
Rounin has quit [Changing host]
Rounin has joined #ruby
dostoyev1ky2 has joined #ruby
gr33n7001 has joined #ruby
enyc_ has joined #ruby
Pixi has quit [*.net *.split]
gr33n7007h has quit [*.net *.split]
brw has quit [*.net *.split]
Artea has quit [*.net *.split]
ruby[bot] has quit [*.net *.split]
Starfoxxes has quit [*.net *.split]
itaipu has quit [*.net *.split]
llua has quit [*.net *.split]
caleb_ has quit [*.net *.split]
enyc has quit [*.net *.split]
pounce has quit [*.net *.split]
meimei has quit [*.net *.split]
dostoyevsky2 has quit [*.net *.split]
Quiet-Oil9262 has quit [*.net *.split]
SaveFerris has quit [*.net *.split]
infernix has quit [*.net *.split]
caleb__ is now known as caleb_
brw9 is now known as brw
Quiet-Oil92622 is now known as Quiet-Oil9262
meimei_ is now known as meimei
SaveFerris3 is now known as SaveFerris
pounce_ is now known as pounce
Starfoxxes has joined #ruby
itaipu has joined #ruby
Artea_ has joined #ruby
Artea_ has quit [Remote host closed the connection]
infernix has joined #ruby
Artea has joined #ruby
Rounin has quit [Quit: Rounin]
Triviality has joined #ruby
cappy has quit [Quit: Leaving]
Rounin has joined #ruby
Rounin has quit [Changing host]
Rounin has joined #ruby
konsolebox has quit [Quit: .]
konsolebox has joined #ruby
Obsdark has joined #ruby
Obsdark has quit [Changing host]
Obsdark has joined #ruby
mtm has quit [Ping timeout: 252 seconds]
mtm has joined #ruby
enyc_ is now known as enyc
dostoyev1ky2 has quit [Quit: leaving]
dostoyevsky2 has joined #ruby
mange has joined #ruby
llua` is now known as llua
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
Rounin has quit [Quit: Rounin]
Linux_Kerio has joined #ruby
kiwi_36 has joined #ruby
oneeyedalien has joined #ruby
<constxd>
bros i got a little codegolf question how would u fill in nil values in one array with values from another array, and then put any leftover elements from the second array at the end
<constxd>
for example: xs=[1, 2, None, 4, None, None, 7] and ys=['a', 'b', 'c', 'd', 'e', 'f']. then you want the result: [1, 2, 'a', 4, 'b', 'c', 7, 'd', 'e', 'f']
<mange>
I mean, yeah, you could keep track of the index instead and walk through the array yourself, but it will be more involved.
<mange>
It's not *that* much worse, but I don't like it as much: i = 0; xs.map { _1.nil? ? ys[i += 1] : _1 } + ys[i..]
<constxd>
hmm
<mange>
Oh, wait, sorry, that's off by one. You'd have to start with i = -1
<mange>
And use ys[(i + 1)..] at the end. I feel like the fact that I've made two off-by-one errors should point you towards the solution that doesn't involve numbers.
<constxd>
this is driving me crazy
dviola has quit [Ping timeout: 260 seconds]
<mange>
What is driving you crazy?
<constxd>
i feel like there should be a very simple solution that doesn't involve any mutation
chen has joined #ruby
<constxd>
consider this related problem too: you want to *add* the nil values to ys at the same indices. so you end up with: ['a', 'b', nil, 'c', nil, nil, 'd', 'e', 'f']
<constxd>
then i think you can just interleave them and remove the nils
<mange>
Why does it need to not involve mutation?
<constxd>
no reason really just an exercise at this point
<mange>
Here you go: yiter = ys.each; result = xs.map { _1.nil? ? yiter.next : _1 }; loop { result << yiter.next } rescue StopIteration; result
<constxd>
the mutating solution will work fine for what i am actually doing
user71 has joined #ruby
<constxd>
what is the type of yiter there
<mange>
Like, you need to track the state of your iteration somehow. Using mutation does it implicitly, by removing values as you consume them. Using an index does it explicitly using random access. Using an enumerator does it implicitly using that protocol (which will work for non-array values like sets).