havenwood changed the topic of #ruby to: Ruby 3.2.2, 3.1.4, 3.3.0-preview1: https://www.ruby-lang.org | Rules: https://ruby-community.com | Logs: https://libera.irclog.whitequark.org/ruby
patrick- has quit [Ping timeout: 245 seconds]
patrick- has joined #ruby
<adam12> johnjaye: There's another require you can use. ruby -rdebug/star
<adam12> johnjaye: ruby -rdebug/start rather
<johnjaye> does that call a class method?
<adam12> I don't know
<johnjaye> well i now have both ruby 3.3 and 2.7 available. so if there are any differences other than keyword args to investigate, let me know
<johnjaye> kinda amazing String used to have #each back in 1.9 times
<adam12> Probably because utf8 support was poor.
<adam12> You'd likely want String#each_grapheme_cluster now.
leon__ has quit [Ping timeout: 258 seconds]
Bindles has quit [Quit: Client closed]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xmachina has joined #ruby
gr33n7007h has quit [Read error: Connection reset by peer]
gr33n7007h has joined #ruby
gr33n7007h has quit [Read error: Connection reset by peer]
ua_ has quit [Ping timeout: 246 seconds]
jmcgnh has quit [Ping timeout: 245 seconds]
gr33n7007h has joined #ruby
ua_ has joined #ruby
jmcgnh has joined #ruby
hightower4 has joined #ruby
hightower3 has quit [Ping timeout: 258 seconds]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 248 seconds]
desnudopenguino1 is now known as desnudopenguino
<ox1eef_> String did not have #each in 1.9 times, that was 1.8 times.1.9 was when it was removed.
<ox1eef_> And, the reason for that was that 1.9 introduced the concept of encodings, where as before strings were essentially a sequence of bytes.
Vonter has joined #ruby
<johnjaye> ox1eef_: to be clear, in ruby equals? is used for object identity, and == for property identity, correct
<johnjaye> meaning, == should always check if the two things have the same length chars nums or whatever
<ox1eef_> No such thing as equals? - it is Object#equal?, and yes, that's asking the question "are these two objects the same object, based on their #object_id" - where as eql? / == are less strict, and can have their own meaning depending on the class.
<johnjaye> er right
<johnjaye> i thought i saw something about == having to be overriden though
<johnjaye> which makes it sound like if i define class Fum and don't define == in it, then == will just report object id equality
<johnjaye> so like it's more a convention than a hard rule
<ox1eef_> It usually derives its meaning from the class, yep.
<johnjaye> ok. i can check it i guess. once i remember how to define operators
<johnjaye> in lisp it's kind of reversed. equals or equal for same properties, and eq or == for identity
<ox1eef_> Nothing special to implement it. def ==(other); end, but you should alias eql? to it (or vice versa).
<johnjaye> pandabot: rb 1==1.0
<ox1eef_> Struct or OpenStruct might be interesting to have a look at, since I'd assume they implement equality based on having the same properties, and String#== is probably interesting too, where equality is based on the contents of the string.
<johnjaye> that's again a convention. with integers it breaks it by making eql less strong? or less big? not sure the right way to say it
brw6 has quit [Quit: The Lounge - https://thelounge.chat]
<ox1eef_> Less strict, and I don't think it is breaking with convention, rather it is following the convention for '==' / eql? to have its meaning derived on a class to class basis.
brw6 has joined #ruby
<ox1eef_> "foo" == "foo" - these are two different objects, but the result is true. And so on.
<johnjaye> pandabot rb 1.eql?(1.0)
<johnjaye> well idk it evals to false.
<ox1eef_> >> 1 == 1.0
<johnjaye> so i thought that means it's more strict in that it won't do the conversion for you. but == will
<ruby[bot]> ox1eef_: # => true (https://carc.in/#/r/fpil)
<johnjaye> so == has more cases it covers
<ox1eef_> It does not evaluate to false. That's clear. Why are you posting false information ?
<johnjaye> eql does. not ==
<johnjaye> >> 1.eql?(1.0)
<ruby[bot]> johnjaye: # => false (https://carc.in/#/r/fpio)
<ox1eef_> Oh my bad. Sorry. That's unlikely to be the intention. == / eql? are thought of as one and the same, and you'd usually alias them.
<johnjaye> oh ok. i thought maybe the thinking was that == would cover more cases or something. i see
<ox1eef_> But, it might be done this way for Hash, I believe Hash determines key equality based on eql? rather than ==.
dviola has quit [Ping timeout: 255 seconds]
<ox1eef_> I guess it depends and has to be determined on a case by case basis, whether or not you alias == to eql?.
<ox1eef_> For example:
<ox1eef_> >> "foo".eql?("foo")
<ruby[bot]> ox1eef_: # => true (https://carc.in/#/r/fpir)
<leftylink> I see, indeed
<leftylink> pandabot rb class C; def hash; 1 end; def ==(_); raise "NOT ALLOWED" end; def eql?(v) print "THANKS FOR CALLING EQL ON #{self} and #{v}! " end end; {C.new => p}[C.new]
<pandabot> THANKS FOR CALLING EQL ON #<C:0x0000559120c26558> and #<C:0x0000559120c266e8>! nil - https://carc.in/#/r/fpit
diego has joined #ruby
<leftylink> weren't there yet another two equalities in Ruby? I keep forgetting and getting things mixed up
diego is now known as Guest1433
<leftylink> ah no just a third one, equal?
<leftylink> it's too easy to get eql? and equal? mixed up since they only differ by a few letters
<leftylink> since I am getting older I will probably never be able to memorise the difference and will be forced always to look it up every time
<ox1eef_> Indeed, but I think there's logic to it. 'equal?' implies a strict equal, and eql? *can* mean something less strict, where the properties might be the same but not the object itself. So it's less of an equal.
<leftylink> I see, since it's less equal, it has fewer letters
<leftylink> yes, that might help me
<leftylink> I like mnemonics
<leftylink> I notice that we are now talking about things being more equal or less equal than other things
<leftylink> all animals are equal
<ox1eef_> xD
grenierm has joined #ruby
_ht has joined #ruby
Hammdist has quit [Quit: Client closed]
fercell has quit [Read error: Connection reset by peer]
fercell has joined #ruby
grenierm has quit [Quit: Client closed]
grenierm has joined #ruby
grenierm has quit [Client Quit]
ua_ has quit [Ping timeout: 248 seconds]
otisolsen70 has joined #ruby
grenierm has joined #ruby
u0_a1152 has joined #ruby
_ht has quit [Quit: _ht]
redruM has quit [Ping timeout: 246 seconds]
konsolebox has joined #ruby
whysthatso125070 has joined #ruby
konsolebox has quit [Ping timeout: 245 seconds]
konsolebox has joined #ruby
u0_a1152 has quit [Ping timeout: 248 seconds]
konsolebox has quit [Ping timeout: 258 seconds]
willfish has joined #ruby
Vonter has quit [Ping timeout: 248 seconds]
grenierm has quit [Ping timeout: 246 seconds]
Vonter has joined #ruby
u0_a1152 has joined #ruby
u0_a1153 has joined #ruby
u0_a1152 has quit [Ping timeout: 245 seconds]
u0_a1153 has quit [Ping timeout: 245 seconds]
u0_a1153 has joined #ruby
konsolebox has joined #ruby
ua_ has joined #ruby
TomyWork has joined #ruby
u0_a1153 has quit [Ping timeout: 246 seconds]
leon__ has joined #ruby
konsolebox has quit [Ping timeout: 245 seconds]
cxl has quit [Quit: bye]
cxl has joined #ruby
taupiqueur_shiny has joined #ruby
Guest1433 has left #ruby [WeeChat 4.0.4]
dviola has joined #ruby
Furai has quit [Quit: WeeChat 4.0.4]
Furai has joined #ruby
konsolebox has joined #ruby
konsolebox has quit [Ping timeout: 240 seconds]
leon__ has quit [Remote host closed the connection]
leon__ has joined #ruby
Hammdist has joined #ruby
xmachina has quit [Quit: WeeChat 4.0.4]
xmachina has joined #ruby
infinityfye has joined #ruby
pounce has quit [Ping timeout: 246 seconds]
pounce has joined #ruby
konsolebox has joined #ruby
<adam12> good morning
<johnjaye> if i had to summarize what i think, i guess equal? is for pointer equality, and == and eql? are for equality of properties, like having the same data or size
<johnjaye> and in some situations eql? and == may be different for convenience. maybe related to Hash somehow
<johnjaye> lisp i've noticed has the same convention, so i'm guessing that's where ruby got it
<ox1eef_> Related to Hash for sure, you want 1 and 1.0 to be distinct keys.
<ox1eef_> Otherwise that sounds right to me, although calling it pointer identity is maybe a bit off on a concept level but it makes sense.
<johnjaye> ah ok in lisp (eql 1 1.0) is false as wel
<ox1eef_> adam12: gmorning
<johnjaye> different topic. but does the ruby gc run at regular intervals?
<johnjaye> i tried benchmarking some code that just appends to an array a million times a string
<johnjaye> I found that the time was linear except for spots where the time spiked up super high
<ox1eef_> Last I heard it was mark and sweep. But I'm not sure that's strictly true anymore.
<ox1eef_> It does stop the world, though.
<johnjaye> hmm. so if i repeated this experiment with any ruby operation not just growing an array I would see those spike?
<ox1eef_> I think so, because the GC blocks your code from running. But I'm no expert on this topic.
<ox1eef_> You might find some answers in gc.c
<ox1eef_> That looks to have the details you're looking for.
<johnjaye> thanks
<adam12> Generative mark and sweep
<adam12> johnjaye: There's a new experimental profiler called Vernier that can show GC calls. https://github.com/jhawthorn/vernier
<ox1eef_> How's that differ to GC::Profiler
<adam12> Not sure, to be honest.
<adam12> Ah, interesting. I'd say Vernier is more full-profiler. With a segment of code, it will show sampled top X frames as well as GC pauses and other things.
<ox1eef_> Nice
yziquel has joined #ruby
<yziquel> what's the default folder to put local user-wide gems into with "bunndle config set --local path" ?
<adam12> yziquel: I don't think there is a default. I sometimes use vendor/bundle
<yziquel> hmmmh.... ok adam12
<yziquel> I like my distribution layout predictable. so i'm a bit disappointed. but ok.
<adam12> yziquel: bundler is usually project-wide if you're using the `local` path option.
<adam12> yziquel: If you want user-wide, you probably want to configure `gem`, which is via GEM_HOME and GEM_PATH.
<yziquel> ok
cognemo has joined #ruby
yziquel has quit [Quit: Client closed]
infinity_fye has joined #ruby
infinityfye has quit [Killed (NickServ (GHOST command used by infinity_fye))]
infinity_fye is now known as infinityfye
<johnjaye> debian has some path called vendor_ruby in /usr/lib
<johnjaye> /usr/lib/ruby/vendor_ruby and things like minitest,ffi,concurrent, and formatador go in it
lucartc has joined #ruby
<lucartc> Does anyone know how to use endless functions with parameters like "def foo(a) = (puts(a) and puts(a))" without the parenthesis around the expression? It sends a NameError if I remove them. I'm using ruby 3.2.0
lucartc has quit [Ping timeout: 244 seconds]
dstein64- has joined #ruby
dstein64 has quit [Ping timeout: 245 seconds]
dstein64- is now known as dstein64
lucartc has joined #ruby
deadmarshal_ has quit [Quit: IRCNow and Forever!]
lester29 has quit [Quit: IRCNow and Forever!]
lucartc has quit [Ping timeout: 246 seconds]
deadmarshal_ has joined #ruby
lester29 has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
taupiqueur_shiny has quit [Ping timeout: 246 seconds]
pounce has quit [Ping timeout: 245 seconds]
pounce has joined #ruby
graywolf has joined #ruby
_ht has joined #ruby
Hammdist has left #ruby [#ruby]
<KOTP> The `puts` with `and` will not make functional sense, because `puts` always returns `nil` and so the right hand side of that expression will not trigger. So functionally, this code would be `def foo(a)= puts a`
willfish has quit [Ping timeout: 260 seconds]
graywolf has quit [Quit: WeeChat 4.0.4]
axsuul has quit [Quit: 👋]
Vonter has quit [Ping timeout: 250 seconds]
Vonter has joined #ruby
willfish has joined #ruby
yziquel has joined #ruby
willfish has quit [Ping timeout: 246 seconds]
TomyWork has quit [Remote host closed the connection]
Vonter has quit [Ping timeout: 246 seconds]
Vonter has joined #ruby
<konsolebox> Also the name error happens because 'and' has lower precedence than the declaration of the method. They already left unfortunately.
axsuul has joined #ruby
leon__ has quit [Ping timeout: 246 seconds]
Vonter has quit [Ping timeout: 246 seconds]
teclator has quit [Ping timeout: 244 seconds]
willfish has joined #ruby
taupiqueur_shiny has joined #ruby
taupiqueur_shiny has quit [Remote host closed the connection]
taupiqueur_shiny has joined #ruby
<johnjaye> pandabot rb "\Aa\z" =~ "A"
<johnjaye> well i messed it up. but this \A is equivalent to ^ and \z to $. they both produce same behavior in a string regexp match
<johnjaye> i haven't seen \A or \z so idk what the purpose is there
<leftylink> no, they're not equivalent. \A is beginning of string, whereas ^ is beginning of line
<leftylink> big difference
<johnjaye> would i need to process a multiline string to see the difference?
<johnjaye> normally regexps only process per line
<johnjaye> and you have some special flag to force multiline
gr33n7007h has quit [Ping timeout: 250 seconds]
gr33n7007h has joined #ruby
<leftylink> if we wanted to validate that a user hasn't entered a malicious command, it would be wrong and insecure to use ^ and $
<leftylink> pandabot: rb "Good stuff".match?(/^Good stuff$/) # WRONG DO NOT DO THIS
<pandabot> true - https://carc.in/#/r/fpm6
<leftylink> okay, but then the user can easily get past the validation and enter a malicious command
<leftylink> pandabot: rb "Good stuff\nmalicious command".match?(/^Good stuff$/) # WRONG AND INSECURE
<pandabot> true - https://carc.in/#/r/fpm8
<leftylink> that's why we have to use \A and \z
<leftylink> pandabot: rb "Good stuff\nmalicious command".match?(/\AGood stuff\z/)
<pandabot> false - https://carc.in/#/r/fpm9
<leftylink> now they did not get past the validation
<johnjaye> hrm. it says here to use /m to enable multiline mode
<johnjaye> it seems strange to me to be using regexps on a multiline string without it
<johnjaye> but i think i get the example
lester29 has left #ruby [WeeChat 4.0.4]
yziquel has quit [Quit: Client closed]
taupiqueur_shiny has quit [Remote host closed the connection]
eddof13 has joined #ruby
lucartc has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has joined #ruby
_ht has quit [Quit: _ht]
otisolsen70 has quit [Quit: Leaving]
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has joined #ruby
<leftylink> I guess I just see it differently. such a flag affects what strings the regular expression accepts. they say nothing about what strings the regular expression will be tested against
<leftylink> it'd be like saying "it seems strange to be using /a/ to match strings without the letter 'a'"
<leftylink> when in fact it isn't strange at all to use /a/ on strings without the letter 'a'
<leftylink> s/to match/on/
infinityfye has quit [Quit: Leaving]
<weaksauc_> johnjaye the m flag modifies what . matches against
<weaksauc_> /./ would be anything except newline and /./m would be any character including newline
<johnjaye> hmm. i wonder if \A is posix then
<johnjaye> i have the idea that beginning of string and beginning of line are interchangeable. but maybe not
<johnjaye> at least if you're going to be feeding in such strings
<weaksauc_> "\n\nsomething\n\nmalicious"
<johnjaye> no i don't see anything here about \A or anything
<weaksauc_> that whole string is many lines
<weaksauc_> and if you pass it in it will not find a match
<johnjaye> is \A unique to ruby then?
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<weaksauc_> i don't think so no
<johnjaye> this man page says it's in perl.
<johnjaye> interesting. probably just another example of ruby borrowing a useful feature from somewhere
eddof13 has joined #ruby
<weaksauc_> search for \a
<johnjaye> it mentions \A but doesn't specify a source.
<johnjaye> but i think it's from perl
<weaksauc_> technically it's from the regex library that ruby uses
<johnjaye> ruby doesn't use its own regex system?
eddof13 has quit [Client Quit]
<weaksauc_> nope
<weaksauc_> maybe now since they forked it but they use a regex library https://en.wikipedia.org/wiki/Oniguruma
<johnjaye> the source says Onigmo library
<weaksauc_> yeah that is the fork
<johnjaye> ah i see. i didn't even know there were different regex libraries
<johnjaye> i vaguely know there's a gnu-flavored one
<weaksauc_> yeah that's not something most people would want to write
<weaksauc_> for a project
<johnjaye> amazing. in addition to perl and gnu there's glib, several java ones, oniguruma, QT, Boost, and several miscellaneous ones
<johnjaye> gmail has their own called RE2. according to wikipedia it's the *only one* using a state machine and hence guarantees O(n) space usage
yziquel has joined #ruby
konsolebox has quit [Ping timeout: 246 seconds]
<myappie> seo.rb: A collection of experimental, AI-powered SEO tools with the power to disrupt whatever industry it sets to target. This project is highly classified - DO NOT DISTRIBUTE.
Furai has quit [Quit: WeeChat 4.0.4]
duderonomy has quit [Quit: Textual IRC Client: www.textualapp.com]
Furai has joined #ruby
konsolebox has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
duderonomy has joined #ruby
neshpion has joined #ruby
b3lm0nt has joined #ruby
mags has joined #ruby
willfish has quit [Ping timeout: 246 seconds]
grenierm has joined #ruby
eddof13 has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]