elcuervo has quit [Read error: Connection reset by peer]
vondruch has quit [Ping timeout: 264 seconds]
TCZ has joined #ruby
burgestrand has quit [Quit: burgestrand]
pwnd_nsfw has quit [Quit: Leaving]
drincruz has joined #ruby
troulouliou_dev has joined #ruby
blackmesa has joined #ruby
troulouliou_dev has quit [Quit: Leaving]
sh7d has joined #ruby
hiroaki_ has joined #ruby
stryek has joined #ruby
kent\n has quit [Ping timeout: 260 seconds]
vondruch has joined #ruby
kent\n has joined #ruby
conta has quit [Remote host closed the connection]
conta has joined #ruby
rkoller has joined #ruby
conta has quit [Quit: conta]
blackmesa has quit [Ping timeout: 264 seconds]
burgestrand has joined #ruby
blackmesa has joined #ruby
grimgnr has quit [Ping timeout: 260 seconds]
TCZ has quit [Quit: Leaving]
blackmesa has quit [Ping timeout: 256 seconds]
codefriar has joined #ruby
cnsvc has joined #ruby
wymillerlinux has joined #ruby
cnsvc has quit [Ping timeout: 240 seconds]
pwnd_nsfw has joined #ruby
burgestrand has quit [Quit: burgestrand]
conta has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
<rapha>
hmm
<rapha>
i have a nested object through which i /might/ (or not) be able to walk like so: obj['ba_partitioning'][0]['belongs_to_or_copy_of'][0]['ba_xlsx_row']. rn i'm if'ing my way through that (https://gist.github.com/sixtyfive/ae6be1b9f9da814b286a3394cebf26e6) and the other way i could think of would be with begin; …; rescue; nil; end. is there any more suitable/elegant third way?
deathwishdave has joined #ruby
<havenwood>
rapha: #dig
<havenwood>
rapha: Or you're trying to assign?
<havenwood>
rapha: `x` should be assigned to the first tier that exists?
<rapha>
ooooh, like #!/bin/bash, that's a magic comment then, too
<havenwood>
rapha: Then all String literals in this file are frozen, so no need to: ''.freeze
<havenwood>
rapha: That's a shebang.
<havenwood>
#!
<rapha>
well, a special kind of magic comment, no?
<havenwood>
Yup.
<rapha>
okay. so your #frozen_string_literal thing was a recommendation for when i've scoured the whole code for this pattern and made sure i never try to write into these.
<havenwood>
rapha: If ZERO_TOLERANCE wasn't extracted, #exp would be called twice each time #sign is called.
<rapha>
yeah
<havenwood>
rapha: Same if it was extracted to a method, hence extract to constant.
cnsvc has joined #ruby
<rapha>
if sign is used a lot, then this'll save a lot
<havenwood>
rapha: It kinda works out to just use strict hygiene for *never* unnecessarily creating objects or running methods.
deathwishdave has joined #ruby
<havenwood>
rapha: The code still looks nice, arguably nicer. It turns out DRYness is good for both performance and readability.
<havenwood>
I'd say strictly avoid calling methods or creating objects unnecessarily.
<havenwood>
Instead of doing so only in tight loops or performance critical sections.
pwnd_nsfw has quit [Quit: Leaving]
cnsvc has quit [Ping timeout: 240 seconds]
SeepingN has joined #ruby
conta has quit [Quit: conta]
pwnd_nsfw` has joined #ruby
banisterfiend has joined #ruby
lxsameer has quit [Quit: WeeChat 2.8]
inanepenguin has joined #ruby
imode has joined #ruby
impermanence has joined #ruby
shokohsc has quit [Ping timeout: 256 seconds]
ericm has quit [Remote host closed the connection]
shokohsc7 has joined #ruby
<rapha>
damn
blackmesa has joined #ruby
<rapha>
havenwood: sorry, i was waiting outside the barber shop for my girlfriend and then everything went very fast and i had to go in because it was my turn
* rapha
reads
<havenwood>
rapha: It's IRC! No expectation of quick reply for non-help chats. :)
<rapha>
i still felt a little bad :P
<rapha>
and the lines can become blurry between helping and discussing how code could be improved
<rapha>
but yeah, i love the semi-a/synchronous nature of IRC
<havenwood>
rapha: You didn't miss anything. I was just blabbing about how DRY code tends to be both readable and performant.
<apotheon>
It's a good point, blabbed or otherwise.
burgestrand has joined #ruby
<rapha>
i still haven't implemented half of your suggestions though
* rapha
picks back up where he left off
blackmesa has quit [Ping timeout: 240 seconds]
blackmesa has joined #ruby
<rapha>
havenwood: btw, that code you showed, from neural-net-ruby, is that yours?
<apotheon>
I don't know the context of your question for havenwood but this is a very simplistic example of using rescue without do/end when using a non-existent variable.
<apotheon>
Note that it's generally a bad idea to use rescue like that, without being specific about what types of exceptions to catch.
d3bug has joined #ruby
<apotheon>
(because, generally, different types of exceptions should be handled differently, and gob only knows what other exceptions you might accidentally catch by doing this)
<havenwood>
rapha: Show your updated code?
<apotheon>
That's just a rule of thumb, though. There are exceptions to every rule.
<apotheon>
. . . and that statement was my rescue.
<rapha>
(i'll hold out on the frozen_string_literal for now because i'm pretty sure that'll break stuff and i don't want to mix this up with that in my brain)
<havenwood>
rapha: That ^ refactor avoids the warning and uses a bit more functional style.
<rapha>
yeah, i need to read through everything to find out which those are.
<havenwood>
rapha: If you have tests, add it everywhere and run them. :)
<rapha>
mutating strings is too much part of my habits that i could assume i don't do it somewhere.
conta has joined #ruby
<rapha>
and tests and me ... wow ... perhaps if there's going to be programmer retraining gulags somewhere in the future, then that might happen
<havenwood>
rapha: Where I have the `entry_refs =` extract a method.
<rapha>
aaah you're using #find and #fetch together
<havenwood>
rapha: def entry_refs(entries); entries.map { |entry| entry.dig(*REF_ROW) }.compact end
jetchisel has quit [Ping timeout: 260 seconds]
<havenwood>
rapha: Then remove that line from #link_interconnected_entries and change the next to: entry_refs(entries)...
<havenwood>
rapha: You might also consider extracting methods for the `ref_entry =` and `unless ref_entry`.
<havenwood>
rapha: I often extract methods then contemplate which version I like, and proceed with that one.
<havenwood>
It'd quick to try on, see if you like it.
<havenwood>
It's
<rapha>
wait, where's the difference between @catalog['entries'] and @catalog.fetch('entries')? does the latter forego making a copy in memory?
<havenwood>
rapha: The former will return `nil` if there is no matching key. That then leads to mysterious nil errors.
<rapha>
ah, the IndexError thrown by the second...ö
<havenwood>
rapha: The latter raises an error if the key isn't found.
<havenwood>
rapha: Or you can provide a block with your desired alternative behavior.
<rapha>
in that case no need then, 'entries' is guaranteed to be there. need to find nails to use that hammer on, tho!
<havenwood>
rapha: If you know it's going to be there, all the more reason to #fetch.
<havenwood>
rapha: It'd be exceptional for it to not be there.
<rapha>
yes, very exceptional, because that'd mean i'd have removed the line of code that unconditionally puts it there.
<rapha>
so, does that not make the distinction between exceptional and impossible irrelevant?
<rapha>
(this is bordering on the philosophical now, i know...)
<havenwood>
rapha: Sometimes expected keys aren't there. It just happens.
<havenwood>
rapha: I don't want a `nil` in that case!
<havenwood>
rapha: I want an exception, pointing me to the exact line.
<havenwood>
rapha: I see your point.
chalkmonster has joined #ruby
<rapha>
i do, because i want a nil error, because i want everything to go up in smoke, because i just fucked up
<rapha>
:-D
<rapha>
aaaah okay
<havenwood>
rapha: That `nil` will travel and blow up elsewhere.
<rapha>
no i see your point, too, though
<rapha>
+w
<havenwood>
nil exceptions suck
<rapha>
fair enough, fetch it is
* rapha
has a lot of code to refactor after this session
<havenwood>
rapha: It also signals to the reader.
<havenwood>
rapha: *You* know it's going to be there for sure. I didn't.
<havenwood>
If you had a #fetch rather than #[], I'd have known too.
<rapha>
that's nice. it's a way of telling your future self: buddy, i know you're older now and longing back for your youth even more. but see, i was mindful of your future struggles back then.
<havenwood>
And knowing that would have helped me understand the flow of the program and assist me in making channges.
<rapha>
does make it more readable and feels more robust, too, even though i need to practice those things more
<havenwood>
al2o3-cr: I like it.
<al2o3-cr>
havenwood: ;)
<havenwood>
al2o3-cr: PR to Pry to fix it for everyone?
<al2o3-cr>
havenwood: i would
chouhoulis has joined #ruby
NEETzsche has joined #ruby
<NEETzsche>
Hi there.
<NEETzsche>
I have a weird issue I'm having trouble with.
<NEETzsche>
You know how you can put a path: "/some/path/" in your Gemfile?
<havenwood>
NEETzsche: Yes.
<NEETzsche>
Well, when I change the code in that directory, it doesn't appear to actually run it, even if I type `bundle` in the referencing project
<havenwood>
al2o3-cr: Or I guess: pry.binding_stack = [TOPLEVEL_BINDING]
<al2o3-cr>
havenwood: that would work too ;)
<NEETzsche>
I tried `bundle install`, `bundle`, and `bundle update`. Is there something else I ought to be doing?
jetchisel has quit [Ping timeout: 240 seconds]
<banisterfiend>
ok
<havenwood>
NEETzsche: Just to clarify, you have a local gem and you added its path via a keyword argument to a #gem directive and it's not being added to your bundle?
<NEETzsche>
It says it's added but then I can't require it.
<NEETzsche>
I can't go into irb and go `require jekyll-import` (I'm trying to patch it)