<User4588>
Hi, I would like to use Array#select or equivalent to select index and not value, how do Ido?
<wnd>
User458764, maybe you're looking for Array#index
hiroaki has joined #ruby
<wnd>
on another thought, maybe you wanted all matching indices
Cubixusin[m] has quit [Quit: Idle for 30+ days]
StarOnD has joined #ruby
<User4588>
wnd yes I would like to return multiple indexes for examples indexes of all odd values for (1..10)
<wnd>
my first takes would be `%i[a b a].each_with_index.select { |a, i| a == :a }.map(&:last)` and `%i[a b a].each_with_index.each_with_object([]) { |(v, i), o| o.push(i) if v == :a }` (for fewer objects), but there must be better approaches
<wnd>
don't mind the unnecessary variable in the former :-)
split-brain has joined #ruby
<User4588>
wnd ok thanks I will adapt the former to my purpose
<azidhaka>
Hi everyone, quick question, in this error log: http://p.ip.fi/-lZm which is the function that last caused the error, is it at the top or at the bottom?
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
miojofu has joined #ruby
Rounin has joined #ruby
linuus is now known as linusmarton
linusmarton has quit [Quit: authenticating]
linusmarton has joined #ruby
miojofu has quit [Ping timeout: 240 seconds]
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
<leftylink>
The order of backtraces had been reversed with Ruby 2.5; this change has been reverted. Now backtraces behave like in Ruby 2.4: an error message and the line number where the exception occurs are printed first, and its callers are printed later.
<leftylink>
so in Ruby 2.5, Ruby 2.6, Ruby 2.7, it's the opposite way of what's said above, otherwise it's what's said above
bsdbandit-01 has quit [Ping timeout: 246 seconds]
Sellow has joined #ruby
<giorgian>
leftylink: wow, thank you, I didn't know it had been reverted
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
Rudd0^ has joined #ruby
roadt_ has joined #ruby
jinie has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
Rudd0 has quit [Ping timeout: 260 seconds]
roadt__ has quit [Ping timeout: 265 seconds]
va5c0 has joined #ruby
MalkbabY has quit [Remote host closed the connection]
MalkbabY has joined #ruby
mixfix41 has quit [Ping timeout: 264 seconds]
al2o3-cr has joined #ruby
miojo has joined #ruby
ur5us has joined #ruby
<al2o3-cr>
User4588: (1..10).filter_map.with_index { _2 if _1.odd? }
<NL3limin4t0r_afk>
User4588: You could also use #each_index instead of #each_with_index. `array.each_index.select { |i| array[i] == 'something' }`
NL3limin4t0r_afk is now known as NL3limin4t0r
bsdbandit-01 has joined #ruby
m27frogy has joined #ruby
<NL3limin4t0r>
leftylink: I'm personally glad that they reverted the upside down backtrace. The pre 2.5 backtrace order is the way most programming languages do things. I find it also most logical, since you read from to to bottom. Having the important thing (the exception) printed first, followed by the cause is more logical then first mentioning the cause then telling me what went wrong.
<NL3limin4t0r>
from top* to bottom
naftilos76 has joined #ruby
<NL3limin4t0r>
A good comparison would be something like "I have a broken arm because I fell wrong during snowbording" vs "I fell wrong during snowbording, now I have a broken arm" then imagine the cause to be a full paragraph.
gray-_-wolf has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
postmodern has quit [Quit: Leaving]
<User4588>
al2o3-cr nice one with this filter_map method could you tell me how there underscore parameters are called?
<al2o3-cr>
User4588: numbered parameters
<User4588>
al2o3-cr thx
<al2o3-cr>
User4588: yw :)
<NL3limin4t0r>
User4588: It's a shortcut for `.with_index { |n, i| i if n.odd? }`
bsdbandit-01 has quit [Read error: Connection reset by peer]
cutiepie has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
StarOnD has quit [Quit: Connection closed]
bsdbandit-01 has joined #ruby
NL3limin4t0r has quit [Quit: WeeChat 1.9.1]
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
rprimus has quit [Quit: leaving]
rprimus has joined #ruby
ruurd has joined #ruby
wallacer has joined #ruby
crankharder has joined #ruby
Iarfen has joined #ruby
gray-_-wolf has quit [Quit: WeeChat 3.0]
cow[moo] has joined #ruby
NL3limin4t0r has joined #ruby
TCZ has joined #ruby
bsdbandit-01 has joined #ruby
camilasan_ has quit [Ping timeout: 265 seconds]
camilasan has quit [Ping timeout: 265 seconds]
camilasan has joined #ruby
camilasan_ has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
<leftylink>
that seems to correspond to the question "how does one run an external command in Ruby" - perhaps that search term will give useful results
crankharder has joined #ruby
akem has quit [Quit: Lost terminal]
akem has joined #ruby
vondruch has joined #ruby
Technodrome has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
rapha has joined #ruby
<rapha>
hi all
<NL3limin4t0r>
o/
<rapha>
so i just wrote 9 lines of code to figure out which of two arrays has more elements and pad the other one with nil until they're both the same length
<rapha>
there's got to be a succinct one-liner for that, no?
<leftylink>
Array#fill will help with the second half
<rapha>
oh! TIL!
<rapha>
and the first part, is "if a1.size < a2.size; ...; elsif a2.size < a1.size; ...; end" the only option?
<rapha>
oh wait ... just fill both to the respective other's size
jobewan has quit [Quit: jobewan]
va5c0 has quit [Ping timeout: 265 seconds]
<leftylink>
oh, that'd do it, yeah. I didn't put a lot of thought into the first part
TCZ has joined #ruby
Iarfen has quit [Ping timeout: 265 seconds]
naftilos76 has quit [Ping timeout: 256 seconds]
bsdbandit-01 has joined #ruby
Swyper has joined #ruby
Tempesta has quit [Quit: AdiIRC is updating to v4.1 Beta Build (2021/03/19 UTC) 64 Bit]
Tempesta has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
<al2o3-cr>
rapha: if you know the two arrays are different sizes and never equal, you could do something like this:
<al2o3-cr>
&>> a = [*1..rand(20)]; b = [*1..rand(20)]; (a <=> b) == -1 ? a.fill(nil, b.size, 0) : b.fill(nil, a.size, 0); [a, b]
<NL3limin4t0r>
al2o3-cr: So something like `[a, b].sort_by(&:size).reverse.reduce(:zip).transpose` with the only problem being that you loose track of what where `a` and `b` are in the result.
<NL3limin4t0r>
of what where -> of where*
cthulchu has joined #ruby
<al2o3-cr>
NL3limin4t0r: yup, silly me.
<al2o3-cr>
NL3limin4t0r: why not [a, b].max_by.inject(:zip).transpose ?
hassox_ has quit [Quit: Leaving...]
bsdbandit-01 has joined #ruby
englosh has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
englosh has left #ruby [#ruby]
va5c0 has joined #ruby
queip has quit [Remote host closed the connection]
queip has joined #ruby
va5c0 has quit [Ping timeout: 246 seconds]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
hassox has joined #ruby
bsdbandit-01 has joined #ruby
cd has joined #ruby
akem has quit [Quit: leaving]
<NL3limin4t0r>
al2o3-cr: I prefer #reduce over #inject, because that is used by a lot of other languages.
Iarfen has quit [Ping timeout: 260 seconds]
<NL3limin4t0r>
The `.max_by.inject` does not work, because #max_by is used as iterator. `.max_by.inject` produces the same result as just `.inject`
akem has joined #ruby
jonhg has quit [Remote host closed the connection]
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
ChmEarl has joined #ruby
jonhg has joined #ruby
Annomy has joined #ruby
<Annomy>
bye
Annomy has quit [Quit: leaving]
<al2o3-cr>
NL3limin4t0r: you're correct. i told it's been a while :)
bsdbandit-01 has joined #ruby
jonhg has quit [Ping timeout: 276 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
Technodrome has joined #ruby
Iarfen has joined #ruby
vondruch has quit [Read error: Connection reset by peer]
vondruch has joined #ruby
s3nd1v0g1us has joined #ruby
gray-_-wolf has joined #ruby
Swyper has quit [Remote host closed the connection]
DaRock has quit [Ping timeout: 245 seconds]
gray-_-wolf has quit [Client Quit]
naftilos76 has joined #ruby
Swyper has joined #ruby
jonhg has joined #ruby
ChmEarl has quit [Quit: Leaving]
Iarfen has quit [Ping timeout: 245 seconds]
DTZUZU has quit [Read error: Connection reset by peer]
Iarfen has joined #ruby
DTZUZU has joined #ruby
Rounin has quit [Ping timeout: 240 seconds]
ruurd has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bsdbandit-01 has quit [Read error: Connection reset by peer]
ChmEarl has joined #ruby
Swyper has quit [Remote host closed the connection]
<NL3limin4t0r>
np, practice makes perfect
crankharder has quit [Ping timeout: 240 seconds]
crankharder has joined #ruby
Swyper has joined #ruby
TCZ has quit [Quit: Czesc]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
Xeago has joined #ruby
ruurd has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
eddof13 has joined #ruby
GodFather has quit [Ping timeout: 246 seconds]
va5c0 has joined #ruby
va5c0 has quit [Ping timeout: 246 seconds]
hiroaki has quit [Ping timeout: 244 seconds]
jenrzzz has joined #ruby
Xeago has quit [Ping timeout: 240 seconds]
cthulchu has quit [Ping timeout: 276 seconds]
Swyper has quit [Remote host closed the connection]
teclator has quit [Remote host closed the connection]
jonhg has quit [Remote host closed the connection]
Swyper has joined #ruby
howdoi has joined #ruby
lockweel has joined #ruby
ua has quit [Ping timeout: 256 seconds]
miojo has quit [Ping timeout: 240 seconds]
miojofu has joined #ruby
ua has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
rubydoc_ is now known as rubydoc
alexherbo2 has joined #ruby
rando25892 has joined #ruby
MalkbabY has quit [Remote host closed the connection]
MalkbabY has joined #ruby
crankharder has quit [Ping timeout: 264 seconds]
crankharder has joined #ruby
eddof13 has quit [Ping timeout: 245 seconds]
cd has quit [Read error: Connection reset by peer]
cd has joined #ruby
zapata has quit [Ping timeout: 244 seconds]
zapata_ has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
Swyper has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 260 seconds]
Swyper has joined #ruby
jonhg has joined #ruby
NL3limin4t0r is now known as NL3limin4t0r_afk
jonhg has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
jonhg has joined #ruby
BTRE has quit [Ping timeout: 264 seconds]
BTRE has joined #ruby
jonhg has quit [Ping timeout: 276 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
va5c0 has joined #ruby
bsdbandit-01 has joined #ruby
va5c0 has quit [Ping timeout: 240 seconds]
akem_ has joined #ruby
akem has quit [Ping timeout: 246 seconds]
bsdbandit-01 has quit [Read error: Connection reset by peer]
cuerbot has quit [Read error: Connection reset by peer]
elcuervo has joined #ruby
<rapha>
hmm i find that with most skills, what also makes perfect is taking times out from it every now and then
<rapha>
allow the brain to consolidate things on its own terms
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
RandomArcher has joined #ruby
weaksauce has joined #ruby
weaksauce has quit [Read error: Connection reset by peer]
jobewan has joined #ruby
jess is now known as JESS
supercoven has quit [Ping timeout: 240 seconds]
naftilos76 has quit [Ping timeout: 246 seconds]
jonhg has joined #ruby
jobewan has quit [Quit: jobewan]
bsdbandit-01 has joined #ruby
naftilos76 has joined #ruby
jonhg has quit [Ping timeout: 240 seconds]
Iarfen has quit [Remote host closed the connection]
bsdbandit-01 has quit [Read error: Connection reset by peer]
JESS is now known as jess
jenrzzz has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
postmodern has joined #ruby
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
weaksauce has joined #ruby
jonhg has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
split-brain has quit [Remote host closed the connection]
gearnode has quit [Ping timeout: 244 seconds]
konsolebox has quit [Quit: .]
cnsvc- is now known as cnsvc
jonhg has quit [Ping timeout: 245 seconds]
akem_ has quit [Quit: leaving]
weaksauce has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
al2o3-cr has quit [Ping timeout: 256 seconds]
RandomArcher has quit [Quit: Konversation terminated!]
mixfix41 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
CommunistWolf is now known as burnies
burnies is now known as bernies
al2o3-cr has joined #ruby
bsdbandit-01 has joined #ruby
bernies is now known as CommunistWolf
TCZ has joined #ruby
SuperLag has quit [Remote host closed the connection]
konsolebox has joined #ruby
giorgian` has joined #ruby
crankhar1er has joined #ruby
shtirlic has quit [Ping timeout: 240 seconds]
hassox_ has joined #ruby
whysthatso2 has joined #ruby
Keltia_ has joined #ruby
Sellow3 has joined #ruby
Mrgoose5 has joined #ruby
GodFather has joined #ruby
Mrgoose has quit [Read error: Connection reset by peer]
adam12 has quit [Read error: Connection reset by peer]
Keltia has quit [Read error: Connection reset by peer]
DTZUZU has quit [Read error: Connection reset by peer]
Mrgoose5 is now known as Mrgoose
whysthatso has quit [Read error: Connection reset by peer]
Sellow has quit [Read error: Connection reset by peer]
gremax has quit [Ping timeout: 246 seconds]
crankharder has quit [Read error: Connection reset by peer]
DTZUZU_ has joined #ruby
Sellow3 is now known as Sellow
hassox has quit [Ping timeout: 246 seconds]
whysthatso2 is now known as whysthatso
iamgr00t_ has quit [Ping timeout: 246 seconds]
giorgian has quit [Ping timeout: 246 seconds]
gremax has joined #ruby
iamgr00t has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
LenPayne has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
crankhar1er has quit [Ping timeout: 256 seconds]
zapata_ is now known as zapata
LenPayne has joined #ruby
DaRock has joined #ruby
gix has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
bsdbandit-01 has joined #ruby
jenrzzz has joined #ruby
crankharder has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
GodFather has quit [Ping timeout: 240 seconds]
jonhg has joined #ruby
bsdbandit-01 has joined #ruby
jenrzzz has quit [Ping timeout: 264 seconds]
GodFather has joined #ruby
naftilos76 has quit [Ping timeout: 240 seconds]
gearnode has joined #ruby
TCZ has quit [Quit: Czesc]
rando25892 has quit [Ping timeout: 240 seconds]
jonhg has quit [Ping timeout: 240 seconds]
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
swaggboi has quit [Quit: C-x C-c]
bsdbandit-01 has quit [Read error: Connection reset by peer]
cd has quit [Quit: cd]
MalkbabY has quit [Remote host closed the connection]
MalkbabY has joined #ruby
swaggboi has joined #ruby
crankharder has quit [Ping timeout: 276 seconds]
GodFather has quit [Ping timeout: 240 seconds]
memcorrupt has joined #ruby
memcorrupt has quit [Client Quit]
weaksauce has joined #ruby
konsolebox has quit [Ping timeout: 246 seconds]
weaksauce has quit [Ping timeout: 244 seconds]
konsolebox has joined #ruby
crankharder has joined #ruby
adam12 has joined #ruby
crankharder has quit [Ping timeout: 240 seconds]
bsdbandit-01 has joined #ruby
GodFather has joined #ruby
TCZ has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]