00:14
jmcantrell has joined #ruby
00:14
jmcantrell is now known as Guest9888
00:14
Guest9888 has quit [Killed (osmium.libera.chat (Nickname regained by services))]
00:14
jmcantrell_ has joined #ruby
00:22
Linux_Kerio has quit [Ping timeout: 248 seconds]
00:24
jmcantrell has quit [Ping timeout: 248 seconds]
00:24
jmcantrell_ is now known as jmcantrell
00:56
cappy has joined #ruby
01:05
whysthatso125070 has quit [Read error: Connection reset by peer]
01:07
whysthatso125070 has joined #ruby
01:46
konsolebox has joined #ruby
02:00
konsolebox has quit [Ping timeout: 250 seconds]
02:02
rvalue has joined #ruby
02:13
konsolebox has joined #ruby
02:25
__jmcantrell__ has joined #ruby
02:25
jmcantrell is now known as Guest4832
02:25
Guest4832 has quit [Killed (molybdenum.libera.chat (Nickname regained by services))]
02:25
__jmcantrell__ is now known as jmcantrell
02:25
jmcantrell_ has joined #ruby
03:00
snoojin has joined #ruby
03:02
jhass has quit [Remote host closed the connection]
03:03
jhass has joined #ruby
03:11
konsolebox has quit [Quit: .]
03:13
cappy has quit [Quit: Leaving]
03:39
konsolebox has joined #ruby
03:56
ih8u2 has quit [Remote host closed the connection]
03:59
ih8u2 has joined #ruby
04:44
zayd is now known as Guest6873
04:50
Fridtjof has joined #ruby
06:16
konsolebox has quit [Ping timeout: 250 seconds]
06:20
snoojin has quit [Quit: Connection closed for inactivity]
07:46
R2robot has quit [Quit: Pull the lever, Kronk. Wrong leverrrrrrr!]
07:47
grenierm has joined #ruby
07:50
R2robot has joined #ruby
08:03
konsolebox has joined #ruby
09:34
<
leftylink >
so if you `break` in the middle of e.g. a `map`, you don't get a result. is there a way to `break` but still get the results that had been up to that point?
09:35
<
leftylink >
pandabot: rb [1, 2, 3, 4, 5].map { |x| x == 4 ? break : x } == [1, 2, 3]
09:35
<
leftylink >
it would be great if I could get that to work
09:37
<
leftylink >
I... I
*guess* take_while is acceptable?????????
09:37
<
leftylink >
pandabot: rb [1, 2, 3, 4, 5].take_while { _1 < 4 }.map(&:itself)
09:44
___nick___ has joined #ruby
10:11
<
o0x1eef >
Or use 'next' instead of 'break'. 'next' will return 'nil' in its place, then you could filter those results with .compact or filter_map.
10:11
___nick___ has joined #ruby
10:12
___nick___ has quit [Client Quit]
10:15
___nick___ has joined #ruby
10:31
user71 has joined #ruby
10:32
Linux_Kerio has joined #ruby
10:41
sarna has quit [Remote host closed the connection]
10:42
sarna has joined #ruby
10:48
<
gr33n7007h >
>> [1, 2, 3, 4, 5].slice_before { |x| x == 4 }.first
10:49
ih8u3 has joined #ruby
10:51
ih8u2 has quit [Ping timeout: 260 seconds]
10:51
ih8u3 is now known as ih8u2
10:53
<
gr33n7007h >
whack on a lazy too if the collection is rather large, so it isn't iterating the entire array.
10:57
<
havenwood >
leftylink: You can drop the: .map(&:itself)
11:02
konsolebox has quit [Quit: .]
11:12
<
havenwood >
I admit, I like the 3.4 `it` when a single letter variable or `_1` would be used otherwise. 😊
11:13
<
havenwood >
(1..).take_while { it < 4 }
11:16
<
gr33n7007h >
havenwood: kokubun was relentless in making sure `it` made it in 3.4 :P
11:18
<
gr33n7007h >
i admit, i do prefer it to _1
11:24
jmcantrell has quit [Ping timeout: 276 seconds]
11:24
jmcantrell_ is now known as jmcantrell
11:44
grenierm has quit [Ping timeout: 240 seconds]
12:27
MyNetAz has quit [Remote host closed the connection]
12:42
MyNetAz has joined #ruby
13:00
konsolebox has joined #ruby
13:06
___nick___ has quit [Ping timeout: 252 seconds]
13:07
___nick___ has joined #ruby
13:37
MsInput has quit [Quit: WeeChat 4.4.4]
13:40
konsolebox has quit [Ping timeout: 276 seconds]
13:55
___nick___ has quit [Ping timeout: 248 seconds]
13:56
___nick___ has joined #ruby
13:59
konsolebox has joined #ruby
14:02
user71 has quit [Quit: Leaving]
14:04
donofrio has joined #ruby
14:17
donofrio has quit [Ping timeout: 244 seconds]
14:39
JulioPapel has joined #ruby
14:40
JulioPapel has quit [Client Quit]
14:44
konsolebox has quit [Quit: .]
15:34
rvalue has quit [Read error: Connection reset by peer]
15:35
rvalue has joined #ruby
15:46
Tempesta has quit [Quit: See ya!]
15:53
user71 has joined #ruby
15:55
___nick___ has quit [Ping timeout: 244 seconds]
15:55
___nick___ has joined #ruby
16:16
<
o0x1eef >
>> [1, 2,3 4,5
16:17
<
o0x1eef >
>> [1, 2,3 4, 5].filter_map { x == 4 ? next : x }
16:19
<
o0x1eef >
>> [1, 2,3, 4, 5].filter_map { |x| x < 4 ? x : next }
16:19
<
o0x1eef >
>> [1, 2, 3, 4, 5].filter_map { |x| x < 4 }
16:20
<
o0x1eef >
Yeah, I prefer the other alternatives :)
16:21
<
o0x1eef >
If I had to use filter_map I'd replace 'next' with 'nil'
16:26
<
o0x1eef >
I guess the most old school way to express that is: [1,2,3,4,5].select { |x| x < 4 }
16:40
Tempesta has joined #ruby
16:40
___nick___ has quit [Ping timeout: 244 seconds]
16:41
___nick___ has joined #ruby
16:47
jardsonto has quit [Ping timeout: 248 seconds]
17:01
cappy has joined #ruby
17:20
johnjaye has quit [Ping timeout: 244 seconds]
17:24
jardsonto has joined #ruby
17:42
cappy has quit [Ping timeout: 246 seconds]
17:44
___nick___ has quit [Ping timeout: 252 seconds]
17:44
___nick___ has joined #ruby
18:15
MyNetAz has quit [Read error: Connection reset by peer]
18:30
MyNetAz has joined #ruby
19:22
___nick___ has quit [Ping timeout: 248 seconds]
19:49
r3m has quit [Quit: WeeChat 4.5.0-dev]
19:54
r3m has joined #ruby
20:19
donofrio has joined #ruby
20:30
c10l has joined #ruby
20:34
donofrio has quit [Ping timeout: 248 seconds]
20:40
Linux_Kerio has quit [Ping timeout: 260 seconds]
20:45
hansolo has quit [Ping timeout: 244 seconds]
20:55
SaveFerris has joined #ruby
21:12
jmcantrell has joined #ruby
21:12
jmcantrell has quit [Killed (tantalum.libera.chat (Nickname regained by services))]
21:13
jmcantrell_ has joined #ruby
21:15
hansolo has joined #ruby
21:44
user71 has quit [Quit: Leaving]
21:47
smp_ has joined #ruby
21:47
smp has quit [Ping timeout: 276 seconds]
21:47
smp_ is now known as smp
22:04
Starfoxxes has joined #ruby
22:48
snoojin has joined #ruby
23:00
ruby[bot] has quit [Remote host closed the connection]
23:00
ruby[bot] has joined #ruby
23:00
cappy has joined #ruby
23:53
<
gr33n7007h >
o0x1eef: why spoil a good method by telling the truth?