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
roadie has joined #ruby
motherr has joined #ruby
roadie has quit [Ping timeout: 258 seconds]
postmodern has joined #ruby
flooose has quit [Ping timeout: 240 seconds]
cAMP has left #ruby [#ruby]
Rounin has quit [Ping timeout: 248 seconds]
reset has quit [Quit: reset]
nesoi has joined #ruby
desnudopenguino has quit [Remote host closed the connection]
desnudopenguino has joined #ruby
motherr has quit [Quit: zzz]
orbyt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
postmodern has quit [Read error: Connection reset by peer]
Danishman has joined #ruby
gr33n7007h has quit [Ping timeout: 252 seconds]
ur5us has quit [Ping timeout: 240 seconds]
mune has joined #ruby
dyCrazyEd is now known as CrazyEddy
gggp has joined #ruby
mune has quit [Ping timeout: 250 seconds]
gggp_ has joined #ruby
gggp has quit [Ping timeout: 252 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 240 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
roadie has joined #ruby
mune has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
mmalter has quit [Quit: Lost terminal]
roadie has joined #ruby
mune has quit [Ping timeout: 250 seconds]
ur5us has joined #ruby
mune has joined #ruby
mune has quit [Read error: Connection reset by peer]
ur5us has quit [Quit: Leaving]
ur5us has joined #ruby
roadie has quit [Ping timeout: 240 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
roadie has joined #ruby
kiki_lamb has joined #ruby
kiki_lamb has quit [Client Quit]
kiki_lamb has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
jpw has joined #ruby
roadie has joined #ruby
fdan has joined #ruby
gggp__ has joined #ruby
gggp_ has quit [Ping timeout: 240 seconds]
roadie has quit [Ping timeout: 240 seconds]
_ht has joined #ruby
roadie has joined #ruby
jrgriffiniii has joined #ruby
<jrgriffiniii> list
Danishman has quit [Quit: Leaving]
jrgriffiniii has quit []
fdan has quit [Quit: Client closed]
fdan has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
jetchisel has joined #ruby
roadie has quit [Ping timeout: 240 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
roadie has joined #ruby
nesoi has quit [Quit: Leaving.]
Rounin has joined #ruby
Oxfuxxx has quit [Quit: brb]
michigan has joined #ruby
mjh has joined #ruby
Oxfuxxx has joined #ruby
rubion has joined #ruby
rubion has quit [Ping timeout: 252 seconds]
Tuor has joined #ruby
Oxfuxxx has quit [Ping timeout: 250 seconds]
Oxfuxxx has joined #ruby
noa has joined #ruby
flooose has joined #ruby
random-jellyfish has joined #ruby
<rapha> hi all
<rapha> i'm trying to monkeypatch Array, but in order to not make a mess, i've tried putting the monkeypatched Array as well as my own class into a module. unfortunately, inside my own class, the monkeypatched Array isn't available. what's the trick here?
<rapha> hmm, okay, found a way that might be even cleaner: https://gist.github.com/sixtyfive/2ed46c7f3e3730532bb9491eb177de7b
<nakilon> rapha if you want to patch it only for one module you might want to use refinement
<rapha> oh, hi nakilon
<nakilon> oh you are adding a new method
<nakilon> hi
<rapha> yeah
<rapha> well, need more than one ... but MWE and so on
<nakilon> I mean I don't usually call it monkeypatch if it's not redefining existing stuff
<rapha> hmm that makes sense
<rapha> so you call it refinement?
<nakilon> do you really want to use Arrays in your program? maybe derive a class from Array?
<nakilon> also for this specific case you probably can define the Enumerator utf8_encode and then use it like myobj.utf8_encode.each
<rapha> hmm, what's wrong with arrays?
<rapha> ah, you mean it's more semantically sensible
<rapha> i agree, but that'd be too much effort in this case
<nakilon> maybe some dependency will break becuase of using the Arrays and suddenly there is a new method in it
<rapha> since it's all in one file i don't worry about that
<rapha> if this were a Gem or so, your method of defining an enumerator sounds really nice
<nakilon> and by refinement I mean the https://docs.ruby-lang.org/en/2.4.0/syntax/refinements_rdoc.html see the examples where they do "refine Array"
<nakilon> but yeah, irrelevant for you if it's one file large proram with no deps
random-jellyfish has quit [Ping timeout: 246 seconds]
<rapha> still, TIL a lot ... спасибо :)
<nakilon> на здоровье )
<nakilon> actually the "refine Array" example looks similar to your code
<rapha> oh! водка!
<rapha> yeah, just thought the same thing
<rapha> i'll change it to make use of the refine keyword just for practice
teclator has joined #ruby
jhawthorn has quit [Ping timeout: 248 seconds]
jhawthorn has joined #ruby
mrkz_c has quit [Quit: Connection closed for inactivity]
random-jellyfish has joined #ruby
motherr has joined #ruby
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
roadt has quit [Ping timeout: 240 seconds]
roadt has joined #ruby
Guest53 has joined #ruby
roadie has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
motherr has quit [Quit: zzz]
<Tuor> Hi, when installing gems with `bundle install` what happens if two different projects do need a gem in different version? projectA needs gem1 in Version 3.0 and projectB needs the same gem1 in version 4.0
noa has quit [Ping timeout: 250 seconds]
gr33n7007h has joined #ruby
random-jellyfish has quit [Ping timeout: 246 seconds]
venue has quit [Quit: adios]
Oxfuxxx has quit [Ping timeout: 250 seconds]
Oxfuxxx has joined #ruby
noa has joined #ruby
<aesthetikx> Tuor: both versions will be installed and available. Type something like `gem which rails` to see where your gems are installed, then go to that directory to see all the different versions of all the gems you have installed.
<aesthetikx> This also applies to different ruby versions, if you are using something like rbenv
danjo9 has joined #ruby
fdan has quit [Quit: Client closed]
danjo has quit [Ping timeout: 268 seconds]
danjo9 is now known as danjo
<nakilon> Tuor different projects use different Gemfile
<Tuor> I'm using rbenv.
<Tuor> so ruby will know because of the Gemfile which of the installed versions of a gem has to be used in an application?
<nakilon> yes, if you launch it with 'bundle exec'
<rapha> hmm
<rapha> okay now i tried to add a bang method to String
<rapha> but `class String; self.replace("blah"); end` doesn't work at all (like it used to) because self is ofc frozen in ruby3
<rapha> how does one write that kind of bang method now? o_O
<rapha> oh, nevermind, the input is frozen already
<Tuor> ah ok thx
<rapha> but there must be a way to create an unfrozen string
<rapha> aside from the global # frozen_string_literal: true that is
<rapha> er, false
<gr33n7007h> rapha: +str
<rapha> huh? like, literally put a + in front?
* rapha tries
<rapha> wow, go figure
entel_ has quit [Quit: Connection closed for inactivity]
<aesthetikx> Tuor: Gemfile.lock is what actually lists the (ruby version and) gem versions
<aesthetikx> rapha: yeah I did not know that either
<gr33n7007h> rapha: String#+@ literally is self.dup if self is frozen.
<rapha> more TIL
<rapha> thx :)
noa has quit [Ping timeout: 250 seconds]
dviola has quit [Quit: WeeChat 3.2]
flooose has quit [Ping timeout: 240 seconds]
Guest53 has quit [Ping timeout: 246 seconds]
xuochi has joined #ruby
aeris has quit [Remote host closed the connection]
aeris has joined #ruby
Guest49 has joined #ruby
jetchisel has quit [Ping timeout: 250 seconds]
kwilczynski has quit [Ping timeout: 240 seconds]
r0bby has quit [Read error: Connection reset by peer]
kwilczynski has joined #ruby
r0bby has joined #ruby
noa has joined #ruby
<rapha> wow, weird quantum physics phenomenon here
<rapha> >> h={foo: 'bar', bar: [1,2,3]}; h.map{|k,v| puts v.class; [k,(v.class==Array?puts 'array':puts 'no array')]}
<rapha> damn bot
roadt has quit [Ping timeout: 252 seconds]
roadt has joined #ruby
<rapha> also, in irb it's working
<rapha> why is it always giving "no array" in my code
gr33n7007h has quit [Ping timeout: 252 seconds]
gr33n7007h has joined #ruby
bit4bit has joined #ruby
jpw has quit [Ping timeout: 240 seconds]
dachi_ has joined #ruby
<rapha> wow, so it works if it's not in a module. once you copy and paste it into a module, it stops working. crazy.
dachinat has quit [Ping timeout: 268 seconds]
<jhass[m]> rapha: sure it's just any module? Does it work with ::Array ?
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
<rapha> jhass[m]: so far i'm not able to reproduce it inside of a minimal example.
<rapha> there's a lot of non-ASCII unicode chars in that file though. i think i'll go home, have dinner, prune the aquarium plants, watch a nice show, then try this again in bed.
howdoi has joined #ruby
<howdoi> arr << topic
<howdoi> arr << topic.gsub(":", "_global:")
<howdoi> Can this be rewritten?
gr33n7007h has quit [Quit: WeeChat 3.2]
kiki_lamb has quit [Ping timeout: 248 seconds]
gr33n7007h has joined #ruby
<aesthetikx> not that i can see howdoi
<aesthetikx> I mean I could come up with stuff, but nothing shorter really
<howdoi> okies, it is from each_with_object([]) do |topic, arr|
Guest49 has quit [Quit: Client closed]
dachi__ has joined #ruby
dachi_ has quit [Ping timeout: 252 seconds]
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 250 seconds]
dachi__ has quit [Quit: Leaving]
<jhass[m]> could .flat_map {|topic| [topic, topic.gsub(":", "_global:") } or if order is not important stuff + stuff.map {|topic| topic.gusb(":", "_global:") }
Oxfuxxx has quit [Ping timeout: 240 seconds]
dachinat has joined #ruby
dviola has joined #ruby
gggp__ has quit [Ping timeout: 250 seconds]
kiki_lamb has joined #ruby
jpw has joined #ruby
kiki_lamb has quit [Ping timeout: 252 seconds]
gggp__ has joined #ruby
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 268 seconds]
bit4bit has quit [Quit: Leaving]
Oxfuxxx has joined #ruby
gggp__ has quit [Ping timeout: 268 seconds]
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 252 seconds]
michigan has quit []
roadie has joined #ruby
kiki_lamb has joined #ruby
entel_ has joined #ruby
kiki_lamb has quit [Ping timeout: 248 seconds]
reset has joined #ruby
kiki_lamb has joined #ruby
rubion has joined #ruby
kiki_lamb has quit [Ping timeout: 250 seconds]
orbyt has joined #ruby
Oxfuxxx has quit [Ping timeout: 250 seconds]
Oxfuxxx has joined #ruby
noa has quit [Ping timeout: 248 seconds]
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 268 seconds]
kwilczynski has quit []
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 248 seconds]
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 250 seconds]
venue has joined #ruby
mrkz_c has joined #ruby
roadie has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
motherr has joined #ruby
noa has joined #ruby
kiki_lamb has joined #ruby
motherr has quit [Ping timeout: 252 seconds]
kiki_lamb has quit [Ping timeout: 268 seconds]
flooose has joined #ruby
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 252 seconds]
mirko_ has joined #ruby
_ht has quit [Remote host closed the connection]
<mirko_> 'lo, ruby newbie here.. I'm trying to manually raise an IO::WaitReadable exception and fail doing so. What would be the correct way?
<dachinat> What you raise has to be exception object
<dachinat> IO:WaitReadable is not I think
<mirko_> i'm confused - isn't it a class deriving from the standard exception which i "just" should be able to raise?
pandabot has joined #ruby
<leftylink> pandabot: rb IO::WaitReadable.class
<pandabot> stderr: playpen: timeout triggered! - exit 1 - https://carc.in/#/r/bsle
<leftylink> pandabot: rb IO::WaitReadable.class
<pandabot> Module - https://carc.in/#/r/bslf
<leftylink> so no, it's not an exception.
<leftylink> it's a module
<mirko_> ok, but it can be caught - via "rescue IO::WaitReadable"
<mirko_> so something can raise it - no?
<leftylink> I don't think that means much. I can rescue anything I want
<leftylink> pandabot: rb begin 5; rescue adsfahdsfjahdsfkjashd; end
<leftylink> that adsfahdsfjahdsfkjashd obviousy doesn't exist
<adam12> mirko_: What are you doing, at a higher level?
<adam12> mirko_: Could you raise something like IO::EAGAINWaitReadable? I hesitate to suggest it without knowing what you're doing, but essentially I suspect that one of the classes that might be raised that you're rescuing.
<adam12> mirko_: IO::WaitReadable is a module that's mixed into IO::EAGAINWaitReadable, so that's why the rescue works, as it's in the ancestor tree... or at least I suspect that's what is going on but didn't look too close.
fmccann has joined #ruby
<adam12> Maybe you want a rescue/re-raise, and raise your own exception that you can raise.
<mirko_> yeah, let me explain what i'mt rying to achieve: i'm rescueing a couple of exceptions when handling serial communication (UART but also ACM) and i see various types of exceptions can be thrown. when trying to catch them all, rubocop complains about one exception shadowing the other. so i figured to better my understanding, i should throw e.g. IO::WaitReadable manually and will then be able to see if "rescue
<mirko_> IO::EGAIN" catches it or doesn't
<mirko_> EOFError, Errno::EIO, IO::WaitReadable, IO:EAGAINWaitReadable ..
<mirko_> rescueing IO::WaitReadable, IO:EAGAINWaitReadable e.g. rubocop tells me no-no, because of one shadowing the other (not help that it doesn't tell me which one shadows the other exactly)
<adam12> >> IO::EAGAINWaitReadable.ancestors
<ruby[bot]> adam12: # => [IO::EAGAINWaitReadable, IO::WaitReadable, Errno::EAGAIN, SystemCallError, StandardError, Exception, ...check link for more (https://carc.in/#/r/bslj)
<adam12> I suspect it's `IO::WaitReadable`. It's kind of an "alias" for rescue, in the sense that exceptions that include it can be matched in the rescue (Maybe because of === but again I'm not 100%).
<mirko_> does that mean i should rescue IO::WaitReadable and Errno::EAGAIN and then i should be fine?
<adam12> You could maybe make your own to demonstrate this.
<adam12> Probably.
<adam12> >> Errno::EAGAIN.ancstors.include? IO::WaitReadable
<ruby[bot]> adam12: # => undefined method `ancstors' for Errno::EAGAIN:Class ...check link for more (https://carc.in/#/r/bslk)
<adam12> Oops. Answer is false, so you should be fine and it wouldn't be shadowing.
<mirko_> ok, will try - thanks!
<mirko_> "rescue EAGAIN" or "rescue Errno::EAGAIN" ?
<nakilon> arr << topic << topic.gsub(":", "_global:")
<nakilon> (if this works in Ruby, didn't really try))
<adam12> mirko_: Errno::EAGAIN
fmccann has quit [Quit: My computer has gone to sleep 😴]
kiki_lamb has joined #ruby
fmccann has joined #ruby
fmccann has quit [Client Quit]
kiki_lamb has quit [Ping timeout: 252 seconds]
pwnd_sfw has quit [Quit: Ping timeout (120 seconds)]
noa has quit [Ping timeout: 240 seconds]
random-jellyfish has joined #ruby
pwnd_sfw has joined #ruby
orbyt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 268 seconds]
dachi_ has joined #ruby
dachinat has quit [Ping timeout: 268 seconds]
kiki_lamb has joined #ruby
jetchisel has joined #ruby
kiki_lamb has quit [Ping timeout: 240 seconds]
kiki_lamb has joined #ruby
kiki_lamb has quit [Ping timeout: 248 seconds]
kiki_lamb has joined #ruby
mbrndtgn5 has quit [Quit: The Lounge - https://thelounge.chat]
kiki_lamb has quit [Ping timeout: 268 seconds]
mbrndtgn5 has joined #ruby
kiki_lamb has joined #ruby
noa has joined #ruby
rubion has quit [Ping timeout: 258 seconds]
easbarbosa has joined #ruby
jetchisel has quit [Ping timeout: 252 seconds]
jetchisel has joined #ruby
jetchisel has quit [Remote host closed the connection]
ur5us has joined #ruby
jetchisel has joined #ruby
jetchisel has quit [Ping timeout: 240 seconds]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Ping timeout: 250 seconds]
jetchisel has joined #ruby
jetchisel has quit [Ping timeout: 240 seconds]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Ping timeout: 252 seconds]
jetchisel has joined #ruby
jetchisel has quit [Ping timeout: 248 seconds]
ur5us has quit [Ping timeout: 240 seconds]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
noa has quit [Ping timeout: 240 seconds]
ur5us has joined #ruby
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby
jetchisel has quit [Max SendQ exceeded]
jetchisel has joined #ruby