mark22k has quit [Quit: Ping timeout (120 seconds)]
mark22k has joined #ruby
bambanxx has joined #ruby
jenrzzz has joined #ruby
rvalue has quit [Ping timeout: 268 seconds]
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
rvalue has joined #ruby
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
Vonter has quit [Ping timeout: 256 seconds]
Vonter has joined #ruby
<sam113101>
is there a method that gives the position(s) the item is found in an array? like [0, 1, 2, 3, 4, 6, 3, 5].method(3) = [3, 6]
<adam12>
sam113101: None built in that I am aware of. `index` only returns first and won't support offset. filter_map.with_index would get you what you want. [0, 1, 2, 3, 4, 5, 6, 4, 5, 3].filter_map.with_index { |el, idx| idx if el == 3 }
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
jas-maelstrom has quit [Quit: Leaving]
gr33n7007h has quit [Ping timeout: 272 seconds]
gr33n7007h has joined #ruby
jenrzzz has joined #ruby
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
<havenwood>
I think `filter_map.with_index` should be perfect for most situations. I wrote an Array#indices without an extension to see how it compares, and it's a couple times faster with larger Arrays. https://gist.github.com/havenwood/9a105e9a0077dd81db8497fdd29b7be4
<havenwood>
sam113101: FWIW ^
jenrzzz has joined #ruby
pascal_blaze has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has quit [Ping timeout: 256 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
sam113101 has quit [Remote host closed the connection]
sam113101 has joined #ruby
adam12 has quit [Quit: Ping timeout (120 seconds)]
whysthatso125070 has quit [Quit: Ping timeout (120 seconds)]
adam12 has joined #ruby
whysthatso125070 has joined #ruby
caleb__ has quit [Ping timeout: 256 seconds]
conjunctive has quit [Ping timeout: 256 seconds]
conjunctive has joined #ruby
caleb_ has joined #ruby
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
donofrio__ has joined #ruby
donofrio_ has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 272 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
joako has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
eddof13 has joined #ruby
eddof13 has quit [Client Quit]
rovanion has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
jenrzzz has joined #ruby
RetroPunk has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
Guest15 has joined #ruby
Guest15 has quit [Client Quit]
infernix has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
hightower2 has quit [Ping timeout: 252 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 268 seconds]
hightower2 has joined #ruby
rvalue has joined #ruby
hightower2 has quit [Remote host closed the connection]
hightower2 has joined #ruby
hightower2 has quit [Remote host closed the connection]
hightower2 has joined #ruby
hightower2 has quit [Remote host closed the connection]