adam12 changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.0.2, 2.7.4, 2.6.8: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
hololeap_ is now known as hololeap
dviola has quit [Ping timeout: 245 seconds]
dviola has joined #ruby
puts has quit [Quit: Czesc]
dviola has quit [Ping timeout: 265 seconds]
dviola has joined #ruby
Munto has quit [Ping timeout: 252 seconds]
reset has joined #ruby
Munto has joined #ruby
mrkz_c has joined #ruby
joenoon has quit [Ping timeout: 245 seconds]
itok_ has quit [Ping timeout: 240 seconds]
MachinShin_ has quit [Ping timeout: 268 seconds]
pusewic|away_ has quit [Ping timeout: 268 seconds]
mrkz_c has quit [Ping timeout: 252 seconds]
caleb_ has joined #ruby
hwrd_ has quit [Ping timeout: 268 seconds]
rubin55 has quit [Ping timeout: 268 seconds]
vito has quit [Ping timeout: 268 seconds]
rubin55 has joined #ruby
keyvan has quit [Ping timeout: 268 seconds]
joenoon has joined #ruby
r3my has joined #ruby
vito has joined #ruby
JSharp has joined #ruby
itok_ has joined #ruby
mrkz_c has joined #ruby
pjlsergeant has joined #ruby
keyvan has joined #ruby
JayDoubleu has joined #ruby
integral has joined #ruby
jposer has joined #ruby
hwrd_ has joined #ruby
hwrd_ is now known as hwrd
pusewic|away_ has joined #ruby
MachinShin_ has joined #ruby
lad has quit [Ping timeout: 245 seconds]
_whitelogger has joined #ruby
jpw has joined #ruby
CrazyEddy has quit [Ping timeout: 245 seconds]
CrazyEddy has joined #ruby
Rounin has joined #ruby
mrkz_c has quit [Quit: Connection closed for inactivity]
Tempesta has quit [Quit: See ya!]
<nakilon> "https://example.com/"[URI.regexp(%w{ http https })] # => "https://example.com/"
<nakilon> "https://example.com/".split URI.regexp(%w{ http https }) # => ["", "https", "example.com", "/"]
<nakilon> why does it split like that?
<nakilon> I expected []
<nakilon> I need to get all URLs and substrings between them
jpw has quit [Ping timeout: 264 seconds]
<nakilon> should I expect it to always be [str, *[url_part1, url_part2, url_part3, str], str?]
<nakilon> and the :// between parts 1 and 2
<nakilon> oh, probably rather [[str, url_part1, url_part2, url_part3], str?]
_ht has joined #ruby
<nakilon> oops no, there is also an optional query match group
Tempesta has joined #ruby
<nakilon> weird that StringScanner#scan_until in a loop moves the pointer but does not reach the EOS
Rounin has quit [Ping timeout: 252 seconds]
faxmodem has left #ruby [leave.pl]
rhe has quit [Quit: Ping timeout (120 seconds)]
rhe has joined #ruby
rubytest has joined #ruby
<rubytest> Hi
<rubytest> I was testing some stuff and got some unexpected behaviour
<rubytest> https://try.ruby-lang.org/playground/#code=%23+https%3A%2F%2Fstackoverflow.com%2Fa%2F21694593%0A%0Aclass+MyArray+%3C+Array%0A++def+myeach(%26block)%0A++++each(%26block)%0A++end%0A++def+myeach2(f)%0A++++for+x+in+self%0A++++++f.call(x)%0A++++end%0A++end%0A++def+myeach3(%26blk)%0A++++for+x+in+self%0A++++++blk.call(x)%0A++++end%0A++end%0A++def+myeach4(
<rubytest> %26blk)%0A++++f+%3D+-%3E(x)%7Breturn+blk.call(x)%7D%0A++++for+x+in+self%0A++++++f.call(x)%0A++++end%0A++end%0Aend%0A%0Adef+test0%0A++xs+%3D+MyArray%3A%3A%5B%5D(1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7)%0A++xs.each+do+%7Cx%7C%0A++++return+if+x.even%3F%0A++++p+x%0A++end%0Aend%0A%0Adef+test1%0A++xs+%3D+MyArray%3A%3A%5B%5D(1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7)%0A++x
<rubytest> s.each+do+%7Cx%7C%0A++++next+if+x.even%3F%0A++++p+x%0A++end%0Aend%0A%0Adef+test2%0A++xs+%3D+MyArray%3A%3A%5B%5D(1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7)%0A++xs.myeach+do+%7Cx%7C%0A++++next+if+x.even%3F%0A++++p+x%0A++end%0Aend%0A%0Adef+test3%0A++xs+%3D+MyArray%3A%3A%5B%5D(1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7)%0A++%23+xs.myeach2(method(%3Ayo))%0A++xs.myeach2+-%3E
<rubytest> +(x)+do%0A++++return+if+x.even%3F%0A++++p+x%0A++end%0Aend%0A%0Adef+test4%0A++xs+%3D+MyArray%3A%3A%5B%5D(1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7)%0A++xs.each+-%3E+(x)+do%0A++++return+if+x.even%3F%0A++++p+x%0A++end%0Aend%0A%0Adef+test5%0A++xs+%3D+MyArray%3A%3A%5B%5D(1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7)%0A++xs.myeach3+do+%7Cx%7C%0A++++return+if+x.even%3F%0A++++p+
<rubytest> x%0A++end%0Aend%0A%0Adef+test6%0A++xs+%3D+MyArray%3A%3A%5B%5D(1%2C+2%2C+3%2C+4%2C+5%2C+6%2C+7)%0A++xs.myeach4+do+%7Cx%7C%0A++++return+if+x.even%3F%0A++++p+x%0A++end%0Aend%0A%0Adef+yo(x)%0A++return+if+x.even%3F%0A++p+x%0Aend%0A%0Ap+%3Atest0%0Atest0%0Ap+%3Atest1%0Atest1%0Ap+%3Atest2%0Atest2%0Ap+%3Atest3%0Atest3%0A%23+p+%3Atest4%0A%23+test4%0Ap+%3Ates
<rubytest> t5%0Atest5%0Ap+%3Atest6%0Atest6%0A
<rubytest> everything upto test5 seems correct
<rubytest> test6 I was expecting it to print 1, 3, 5, 7 because the return keyword is inside a lambda
<rubytest> "Procs return from the current method, while lambdas return from the lambda itself."
<rubytest> Shouldn't it just return from the lambda?
<rubytest> the code is also here with line numbers https://bpa.st/2EVQ
<rubytest> line 18
<leftylink> true as that may be, the `return` in the block at line 77 returns from `test6`.
puts has joined #ruby
puts has quit [Client Quit]
puts has joined #ruby
___nick___ has joined #ruby
<rubytest> leftylink, it does?
<rubytest> I thought return was a keyword
<rubytest> "return
<rubytest> Exits a method. See methods" hmmm
<rubytest> leftylink so what's the correct way to convert a block into a lambda?
<rubytest> or I guess in this case the return keyword in the block will always refer to the test6 method
<rubytest> hmm
puts has quit [Quit: Czesc]
<leftylink> I don't understand the meaning of the phrase "convert a block into a lambda" in the context of the code https://bpa.st/2EVQ, so I'm unable to provide an answer at this time without further clarification
<rubytest> ok
rubytest has quit [Quit: Client closed]
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
lipoqil has quit [Quit: ZNC 1.6.5+deb1+deb9u2 - http://znc.in]
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
lipoqil has joined #ruby
puts has joined #ruby
hololeap has quit [Ping timeout: 276 seconds]
hololeap has joined #ruby
pwnd_sfw has quit [Quit: Ping timeout (120 seconds)]
CrazyEddy has quit [Ping timeout: 264 seconds]
pwnd_sfw has joined #ruby
Tempesta has quit [Quit: See ya!]
Tempesta has joined #ruby
perrierjouet has quit [Quit: WeeChat 3.3]
puts has quit [Ping timeout: 245 seconds]
puts has joined #ruby
CrazyEddy has joined #ruby
CrazyEddy has quit [Ping timeout: 245 seconds]
CrazyEddy has joined #ruby
puts has quit [Quit: Czesc]
b08x has joined #ruby
Tempesta has quit [Quit: See ya!]
reset has quit [Read error: Connection reset by peer]
Tempesta has joined #ruby
Pixi_ is now known as Pixi
<nakilon> lol that copypasta
<nakilon> block is a syntax sugar for lambda, not vice versa so he shouldn't want to convert in that direction
<nakilon> he just needed to use next ....
teclator has joined #ruby
fredlinhares has joined #ruby
puts has joined #ruby
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
puts has quit [Client Quit]
swaggboi has quit [Quit: C-x C-c]
Oxfuxxx has joined #ruby
swaggboi has joined #ruby
weaksauce has quit [Ping timeout: 264 seconds]
dviola has quit [Changing host]
dviola has joined #ruby
weaksauce has joined #ruby
Milos has quit [Quit: ZNC 1.8.2 - https://znc.in]
Milos has joined #ruby
AndrewYu has quit [Remote host closed the connection]
AndrewYu has joined #ruby
Oxfuxxx has quit [Ping timeout: 264 seconds]
reset has joined #ruby
pwnd_sfw has quit [Quit: Ping timeout (120 seconds)]
pwnd_sfw has joined #ruby
jpw has joined #ruby
Oxfuxxx has joined #ruby
lad has joined #ruby
jpw has quit [Remote host closed the connection]
gcd has joined #ruby
lad has quit [Remote host closed the connection]
graywolf has joined #ruby
roshanavand has joined #ruby
_ht has quit [Remote host closed the connection]
Xeago has quit [Ping timeout: 250 seconds]
phenom_ is now known as phenom
fredlinhares has quit [Quit: WeeChat 2.8]
b08x has quit [Quit: Leaving]
graywolf has quit [Quit: WeeChat 3.3]
Rounin has joined #ruby
roshanavand has quit [Ping timeout: 264 seconds]
roshanavand has joined #ruby
<newton> TIL there is a try.ruby-lang.org tho
Rounin has quit [Ping timeout: 264 seconds]
Munto has quit [Ping timeout: 252 seconds]
<nakilon> yeah it's on the https://www.ruby-lang.org/en/ sidebar; maybe https://ruby-community.com/pages/links could include it too
Munto has joined #ruby
hololeap has quit [Remote host closed the connection]