havenwood changed the topic of #ruby to: Ruby 3.3.4 (3.4.0-preview1) https://www.ruby-lang.org | Logs https://libera.irclog.whitequark.org/ruby
mtm has quit [Ping timeout: 272 seconds]
Guest75 has joined #ruby
mtm has joined #ruby
Guest75 has quit [Client Quit]
some14u has joined #ruby
some14u has quit [Ping timeout: 265 seconds]
factor3 has quit [Quit: The Lounge - https://thelounge.chat]
Guest75 has joined #ruby
Guest75 has quit [Quit: Client closed]
Guest75 has joined #ruby
jace_ has quit [Remote host closed the connection]
Guest75 has quit [Client Quit]
mjacob has joined #ruby
some14u has joined #ruby
some14u has quit [Ping timeout: 252 seconds]
some14u has joined #ruby
some14u has quit [Ping timeout: 246 seconds]
<mjacob> Where can I find an exact description of the syntax of do blocks, especially their precedence relative to method calls?
desnudopenguino has quit [Ping timeout: 246 seconds]
<mjacob> weaksauce: I don’t see method calls and do blocks in the table.
<weaksauce> last line
<weaksauce> { ... } blocks have priority below all listed operations, but do ... end blocks have lower priority.
<mjacob> weaksauce: I don’t really understand “{ ... } blocks have priority below all listed operations, but do ... end blocks have lower priority.”.
<weaksauce> do end has lower than {} does
<mjacob> Is it even possible to mix do blocks and {} blocks?
<weaksauce> var.foo 1 do end is valid while var.foo 1 { } would syntax error
<weaksauce> what do you mean possible to mix?
<weaksauce> you can do var.foo(1) { ... }
<weaksauce> so if you mean mix in that way they are both blocks yeah
<mjacob> I’ve read in various places that do blocks have lower precedence than {} blocks. Unless I’m missing something, this is only relevant if an expression contains both do blocks and {} blocks.
<weaksauce> it's relevant when you are calling it like above
<weaksauce> i think it's good form to generally use parens though
<weaksauce> even with do end
<mjacob> Let’s take an example which is clearer. Of course * has a higher precedence than +. In expressions `a * b ** c` and `a + b ** c` that fact is not relevant because there’s only one of them. Do blocks and {} blocks don’t mix, so I don’t understand how the statement “do blocks have lower precedence than {} blocks” makes sense.
<mjacob> My original example was `expect(…).to have_xpath(…) do … end` where the block is passed to the `.to` method (I think) vs. `expect(…).to receive(…).with(…) do … end` where the block is passed to the `.with` method (I think).
<mjacob> What I’m looking for is a solid mental model (for me and my colleagues), some coding standard to avoid confusion and (ideally) a way to enforce that coding style automatically.
some14u has joined #ruby
<weaksauce> the block is passed to the last method there
<weaksauce> expect(…).to have_xpath(…) do … end
<weaksauce> the block would be passed to have_xpath
<weaksauce> mjacob ^
<weaksauce> the only way to hijack that order is to use parens
some14u has quit [Ping timeout: 252 seconds]
<mjacob> https://0x0.st/Xtz5.rb prints true for `to`
<weaksauce> surprising
<mjacob> Yes ;)
<weaksauce> i guess they meant it when they said lowest priority
some14u has joined #ruby
gastus has quit [Ping timeout: 246 seconds]
gastus has joined #ruby
<weaksauce> the docs are just about the worst too so that doesn't help
some14u has quit [Ping timeout: 246 seconds]
<mjacob> weaksauce: I’ll call it a day and think about this more tomorrow. Thanks for the pointers!
some14u has joined #ruby
some14u has quit [Ping timeout: 260 seconds]
some14u has joined #ruby
some14u has quit [Ping timeout: 246 seconds]
konsolebox has joined #ruby
some14u has joined #ruby
some14u has quit [Ping timeout: 252 seconds]
some14u has joined #ruby
some14u has quit [Ping timeout: 246 seconds]
ih8u1 is now known as ih8u
cappy has joined #ruby
some14u has joined #ruby
some14u has quit [Ping timeout: 260 seconds]
Linux_Kerio has joined #ruby
grenierm has joined #ruby
some14u has joined #ruby
some14u has quit [Ping timeout: 255 seconds]
some14u has joined #ruby
some14u has quit [Ping timeout: 246 seconds]
some14u has joined #ruby
some14u has quit [Ping timeout: 252 seconds]
shiru has joined #ruby
Rounin has quit [Ping timeout: 260 seconds]
cappy has quit [Quit: Leaving]
Rounin has joined #ruby
ua_ has joined #ruby
smp has quit [Ping timeout: 246 seconds]
smp has joined #ruby
some14u has joined #ruby
Linux_Kerio has quit [Ping timeout: 252 seconds]
some14u has quit [Ping timeout: 260 seconds]
TomyWork has joined #ruby
kiwi_36 has quit [Remote host closed the connection]
smp has quit [Ping timeout: 252 seconds]
smp has joined #ruby
shiru has quit [Remote host closed the connection]
grenierm has quit [Ping timeout: 256 seconds]
Guest75 has joined #ruby
Guest75 has quit [Quit: Client closed]
Guest75 has joined #ruby
Guest75 has quit [Quit: Client closed]
Linux_Kerio has joined #ruby
greybeard has joined #ruby
mtm has quit [Ping timeout: 276 seconds]
mtm has joined #ruby
gastus has quit [Ping timeout: 264 seconds]
gastus has joined #ruby
user71 has joined #ruby
Rounin has quit [Remote host closed the connection]
Guest75 has joined #ruby
some14u has joined #ruby
Rounin has joined #ruby
Rounin has quit [Changing host]
Rounin has joined #ruby
some14u has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest75 has quit [Ping timeout: 256 seconds]
joast has quit [Quit: Leaving.]
konsolebox has quit [Quit: .]
aindilis has joined #ruby
some14u has joined #ruby
Hammdist has joined #ruby
<Hammdist> how do I default in ruby? like x={}; y = x[0] ?? 0 where ?? is borrowed from typescript and does not truly work in ruby?
<Hammdist> actually || seems to do what I want
ua_ has quit [Ping timeout: 265 seconds]
ua_ has joined #ruby
greybeard has quit [Changing host]
greybeard has joined #ruby
greybeard has quit [Quit: Leaving.]
greybeard has joined #ruby
TomyWork has quit [Remote host closed the connection]
CRISPR has joined #ruby
rvalue- has joined #ruby
rvalue has quit [Ping timeout: 272 seconds]
rvalue- is now known as rvalue
some14u has quit [Quit: Textual IRC Client: www.textualapp.com]
grenierm has joined #ruby
<adam12> Hammdist: || or ||= will work
<adam12> Hammdist: The catch being that `nil` and `false` are both `falsey`, which means you might have issues where you expect those as values.
<adam12> Hammdist: The solution there being key?`. `x[0] = 0 unless x.key?(0)`
<weaksauce> i use fetch generally for that with a default value like x.fetch(0, 0)
<weaksauce> all of those work though
CRISPR has quit [Ping timeout: 260 seconds]
CRISPR has joined #ruby
user71 has quit [Quit: Leaving]
Vaevictu1 has joined #ruby
<Vaevictu1> do people still use RVM ?
Vaevictu1 is now known as Vaevictus
<Vaevictus> i've been using it for years, and apparently now it won't let user installs happen without trying to update my OS
CRISPR has quit [Ping timeout: 252 seconds]
<Vaevictus> nm, seems to have been a feature "autolibs"
<adam12> Vaevictus: I don't think it's the _most_ popular anymore.
<adam12> I've switched to using Mise just because it manages bun/node/everything else too, and it's one less tool.
CRISPR has joined #ruby
desnudopenguino has joined #ruby
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 260 seconds]
desnudopenguino1 is now known as desnudopenguino
Linux_Kerio has quit [Ping timeout: 248 seconds]
graywolf has joined #ruby
joako has quit [Quit: quit]
joako has joined #ruby
cappy has joined #ruby
greybeard has quit [Quit: Leaving.]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 246 seconds]
desnudopenguino1 is now known as desnudopenguino
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
CRISPR has quit [Ping timeout: 265 seconds]
Pixi` has quit [Quit: Leaving]
joast has joined #ruby
finsternis has joined #ruby
graywolf has quit [Quit: WeeChat 4.4.1]