havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 2.7.2, 2.6.6, 3.0.0-preview1: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.org | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | BLM <3 | Can't talk? Register/identify with NickServ
emptyflask has joined #ruby
silverdust has joined #ruby
duderonomy has joined #ruby
ur5us_ has quit [Ping timeout: 264 seconds]
silverdust has quit [Ping timeout: 260 seconds]
orbyt_ has joined #ruby
silverdust has joined #ruby
silverdust has quit [Ping timeout: 265 seconds]
itok has quit [Ping timeout: 272 seconds]
maleghast has quit [Quit: Textual IRC Client: www.textualapp.com]
itok has joined #ruby
shoshin has quit [Read error: Connection reset by peer]
shoshin has joined #ruby
ur5us_ has joined #ruby
DaRock has joined #ruby
fippy has quit [Quit: Leaving]
ruurd has quit [Quit: ZZZzzz…]
silverdust has joined #ruby
ruurd has joined #ruby
cer0 has quit [Quit: leaving]
dcunit3d has joined #ruby
ruurd has quit [Ping timeout: 246 seconds]
dcunit3d has quit [Ping timeout: 260 seconds]
dcunit3d has joined #ruby
dc has joined #ruby
dc has quit [Client Quit]
ruurd has joined #ruby
roshanavand_ has joined #ruby
roshanavand has quit [Ping timeout: 272 seconds]
roshanavand_ is now known as roshanavand
moldorcoder7 has quit [Quit: %bye mirc%]
siaw23 has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
arahael has joined #ruby
moldorcoder7 has joined #ruby
dc has joined #ruby
gix has quit [Ping timeout: 256 seconds]
dcunit3d has quit [Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/]
silverdust has quit [Ping timeout: 256 seconds]
silverdust has joined #ruby
siaw23 has joined #ruby
openstruct has quit [Ping timeout: 256 seconds]
fippy has joined #ruby
fippy has joined #ruby
silverdust has quit [Ping timeout: 260 seconds]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
silverdust has joined #ruby
bmurt has joined #ruby
silverdust has quit [Ping timeout: 265 seconds]
TCZ has quit [Quit: Leaving]
Rudd0^ has quit [Ping timeout: 265 seconds]
cloud69 has quit [Quit: Connection closed for inactivity]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
silverdust has joined #ruby
openstruct has joined #ruby
openstruct has joined #ruby
openstruct has quit [Changing host]
silverdust has quit [Ping timeout: 256 seconds]
cloud69 has joined #ruby
<cloud69> Hey, so heres the newegg scraper so far:D https://pastebin.com/2wkNUcMw
<leftylink> I wonder if I ask a stupid qusetion and it is seen as insulting like "of course I thought of that, you insult me by even suggesting that I might not have considered that"
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<leftylink> so I notice in that task newegg: :environment, there are a few functions being defined, but nothing is going to call those functions. maybe it is just because I don't konw rake and rake is going to call one of the functions automatically. that's why it's a stupid question
siaw23 has quit [Quit: My Mac Mini has gone to sleep. ZZZzzz…]
kotrcka has joined #ruby
silverdust has joined #ruby
<cloud69> idk. but this rake task from another of my apps works, although its json
<leftylink> well, if it is not known whether rake will automatically call any of the functions that have at that point been defined (and although I don't know rake, it would be a big surprise to me if it did), then it seems that the safest course of action would then to be call one of them.
<cloud69> excellent, ill get right on it! =)
silverdust has quit [Ping timeout: 256 seconds]
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
zacts has quit [Quit: leaving]
kotrcka has quit [Remote host closed the connection]
akem has joined #ruby
tcrypt has joined #ruby
openstruct has quit [Ping timeout: 260 seconds]
orbyt_ has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Rudd0 has joined #ruby
ur5us_ has quit [Ping timeout: 260 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
orbyt_ has joined #ruby
<nakilon> I wonder if moment.js can parse the Time#to_s output
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
cthulchu_ has quit [Ping timeout: 260 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
woodruffw has quit [Ping timeout: 260 seconds]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
woodruffw has joined #ruby
woodruffw has joined #ruby
akem_ has joined #ruby
akem has quit [Ping timeout: 260 seconds]
ChmEarl has quit [Quit: Leaving]
phenom has quit [Ping timeout: 246 seconds]
phenom has joined #ruby
Mrgoose9 has joined #ruby
arahael has left #ruby ["WeeChat 2.7.1"]
Mrgoose9 is now known as Mrgoose
tsujp has quit [Ping timeout: 264 seconds]
tsujp has joined #ruby
bamdad has quit [Ping timeout: 240 seconds]
Mrgoose0 has joined #ruby
baojg has quit [Remote host closed the connection]
Mrgoose has quit [Ping timeout: 240 seconds]
Mrgoose0 is now known as Mrgoose
baojg has joined #ruby
axe has quit [Ping timeout: 256 seconds]
cd has quit [Quit: cd]
emptyflask has quit [Ping timeout: 256 seconds]
arcaos has quit [Quit: Leaving]
bocaneri has joined #ruby
camilasan has quit [Ping timeout: 264 seconds]
camilasan has joined #ruby
Axy has joined #ruby
Mia has quit [Ping timeout: 260 seconds]
cloud69 has quit [Quit: Connection closed for inactivity]
silverdust has joined #ruby
vondruch has joined #ruby
camilasan has quit [Ping timeout: 260 seconds]
burgestrand has joined #ruby
vondruch has quit [Client Quit]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
cloud69 has joined #ruby
Retropikzel has joined #ruby
Glumetu has joined #ruby
vondruch has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
Mia has joined #ruby
plant_enjoyer has joined #ruby
Axy has quit [Ping timeout: 272 seconds]
fippy has quit [Quit: Leaving]
Axy has joined #ruby
Axy has quit [Changing host]
Axy has joined #ruby
Mia has quit [Ping timeout: 264 seconds]
akem_ has quit [Remote host closed the connection]
braincrash has joined #ruby
Mia has joined #ruby
Axy has quit [Ping timeout: 264 seconds]
ur5us_ has joined #ruby
apoc has quit [Ping timeout: 256 seconds]
VicMackey has joined #ruby
mjacob has quit [Remote host closed the connection]
braincrash has quit [Ping timeout: 272 seconds]
bamdad has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
apoc has joined #ruby
dionysus69 has joined #ruby
ruurd has quit [Quit: bye folks]
siaw23 has joined #ruby
Axy has joined #ruby
Axy has joined #ruby
Mia has quit [Read error: Connection reset by peer]
howdoi has quit [Quit: Connection closed for inactivity]
braincrash has joined #ruby
fippy has joined #ruby
Mia has joined #ruby
Mia has joined #ruby
Axy has quit [Ping timeout: 260 seconds]
ur5us_ has quit [Ping timeout: 260 seconds]
clinth has quit [Ping timeout: 272 seconds]
ec has quit [Ping timeout: 264 seconds]
jhill has quit [Ping timeout: 264 seconds]
afisher has quit [Ping timeout: 244 seconds]
englishm has quit [Read error: Connection reset by peer]
Lewix has quit [Read error: Connection reset by peer]
CustosLimen has quit [Read error: Connection reset by peer]
Lewix has joined #ruby
manveru has quit [Ping timeout: 272 seconds]
r3my has quit [Read error: Connection reset by peer]
kozowu has quit [Ping timeout: 260 seconds]
CustosLimen has joined #ruby
r3my has joined #ruby
ec has joined #ruby
jhill has joined #ruby
clinth has joined #ruby
englishm has joined #ruby
afisher has joined #ruby
kevinsjoberg has quit [Ping timeout: 272 seconds]
manveru has joined #ruby
kozowu has joined #ruby
kevinsjoberg has joined #ruby
Mia has quit [Read error: No route to host]
Mia has joined #ruby
Mia has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
dionysus69 has quit [Ping timeout: 258 seconds]
charrit69 has joined #ruby
<leftylink> hmm, just wanted to express my appreciation that `9.times.map { |x| ->y { x + y } }.map { |f| f[0] }` works as advertised
<leftylink> &>> 9.times.map { |x| ->y { x + y } }.map { |f| f[0] }
<rubydoc> # => [0, 1, 2, 3, 4, 5, 6, 7, 8] (https://carc.in/#/r/9xw4)
<leftylink> you don't get that in all languages.. try `fs = [lambda x: x + y for y in range(10)]; [f(0) for f in fs]` in another certain language, for example
Axy has joined #ruby
Mia has quit [Read error: Connection reset by peer]
openstruct has joined #ruby
infinityfye has joined #ruby
openstruct has quit [Ping timeout: 272 seconds]
Axy has quit [Ping timeout: 260 seconds]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
bsdbandit-01 has joined #ruby
Milos has quit [Ping timeout: 260 seconds]
<leftylink> now they're going to think I was specifically insulting the other language
<leftylink> and they'll use this against me when I run for political office
<leftylink> it was just the example that was most available to me at the time and easiest to test. please don't read too far into it
TCZ has joined #ruby
greengriminal has joined #ruby
Milos has joined #ruby
bsdband38 has joined #ruby
<leftylink> maybe they would think it less unfair if I also gave an example in a different language. then it wouldn't be one particular language that I was picking on
<leftylink> which is why I have now prepared this one
<leftylink> package main; import "fmt"; func main() { fs := make([]func(int) int, 10); for i := 0; i < 10; i++ { fs[i] = func(x int) int{ return x + i } }; for _, f := range fs { fmt.Print(f(0)) } }
imode has quit [Ping timeout: 240 seconds]
bsdbandit-01 has quit [Ping timeout: 260 seconds]
<leftylink> at some point I changed the 9 to a 10, but that obviously is not the important part of the problem
Mia has joined #ruby
bsdband38 has quit [Read error: Connection reset by peer]
bsdbandit-01 has joined #ruby
Glumetu has quit [Quit: Glumetu]
Glumetu has joined #ruby
vondruch has quit [Ping timeout: 246 seconds]
maleghast has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
vondruch has joined #ruby
Mia has quit [Read error: Connection reset by peer]
Mia has joined #ruby
Mia has joined #ruby
Mia has quit [Changing host]
braincrash has quit [Ping timeout: 265 seconds]
October has joined #ruby
bambanx has joined #ruby
vondruch has quit [Ping timeout: 264 seconds]
vondruch has joined #ruby
VicMackey has quit [Ping timeout: 258 seconds]
cloud69 has quit [Quit: Connection closed for inactivity]
fercell has joined #ruby
<leah2> why does bundle update tell me i have merge conflicts in the .lock file? it regenerates it anyway no
bsdbandit-01 has quit [Read error: Connection reset by peer]
charrit69 has quit [Ping timeout: 260 seconds]
bmurt has joined #ruby
Rudd0 has quit [Ping timeout: 256 seconds]
TCZ has quit [Quit: Leaving]
cloud69 has joined #ruby
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
dionysus69 has joined #ruby
stryek has joined #ruby
CommunistWolf is now known as slime-mold
slime-mold is now known as CommunistWolf
October has quit [Quit: leaving]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
axe has joined #ruby
dionysus70 has joined #ruby
<adam12> leah2: It uses it as a base line.
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
howdoi has joined #ruby
charrit69 has joined #ruby
burgestrand has quit [Quit: burgestrand]
plant_enjoyer has quit [Quit: Leaving]
nevans has joined #ruby
elcontrastador has joined #ruby
charrit69 has quit [Ping timeout: 240 seconds]
charrit69 has joined #ruby
<leah2> are you saying rm Gemfile.lock && bundle install results in something different than bundle update ?
tcrypt has quit [Read error: Connection reset by peer]
MadLamb has joined #ruby
dionysus70 has quit [Ping timeout: 272 seconds]
<MadLamb> How can I get a json from a ActiveRecord model while mapping to a different structure? Model.find(id).map is giving me "undefined method map".
<adam12> leah2: Yes there's a good chance of that.
ChmEarl has joined #ruby
<adam12> MadLamb: Model.find(id) returns a single instance, and #map is generally called on an Enumerable collection.
<adam12> MadLamb: if just calling `to_json` doesn't work for you, you might need to build your own Hash then call to_json on that.
<adam12> MadLamb: I don't do Rails anymore so maybe someone has a more "Railsly" way of doing it.
<MadLamb> adam12, hmm. In the end I need a json with a different structure
burgestrand has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<MadLamb> adam12, calling map is not really a requirement
Emmanuel_Chanel has quit [Ping timeout: 256 seconds]
infinityfye has quit [Ping timeout: 256 seconds]
<adam12> MadLamb: Model.find(id).then { |record| { id: record.id, name: record.name }.to_json }
infinityfye has joined #ruby
openstruct has joined #ruby
openstruct has joined #ruby
<MadLamb> adam12, undefined method then
TCZ has joined #ruby
<adam12> MadLamb: Ah. What version of Ruby?
<MadLamb> adam12, ruby 2.5.8p224
<MadLamb> with Rails 4.2.11.3
<MadLamb> then is 2.6, right?
<adam12> MadLamb: Yeah.
<MadLamb> :(
<adam12> you could do yield_Self
<adam12> rather, yield_self
<adam12> or just pull it into two lines. record = Model.find(id); { id: record.id, name: record.name }.to_json
openstruct has quit [Ping timeout: 260 seconds]
<MadLamb> adam12, there is a .yield_self
<MadLamb> adam12, that worked
<MadLamb> adam12, yeah that did it. thanks!
<havenwood> MadLamb: Or: Model.limit(1).pluck(:id, :name).first.to_json
<havenwood> Oh, I somehow saw `first` and it's actually `find(id)`.
<havenwood> MadLamb: Or: Model.where(id: id).pluck(:id, :name).first.to_json
<havenwood> And add the #limit back >.>
* havenwood goes for coffee
<adam12> COFFEE
<havenwood> ☕️
<havenwood> A1 okay!
ta has quit [Ping timeout: 260 seconds]
<havenwood> &>> ('a'.ord.to_s.chars + '1'.ord.to_s.chars).join.to_i.chr(Encoding::UTF_8)
<rubydoc> # => "☕" (https://carc.in/#/r/9xxy)
bambanx has quit [Ping timeout: 260 seconds]
<havenwood> &>> 'a1'.chars.map(&:ord).map(&:digits).map(&:reverse).join.to_i.chr(Encoding::UTF_8)
<rubydoc> # => "☕" (https://carc.in/#/r/9xyd)
<havenwood> &>> 'a1'.chars.map(&:ord).map(&:digits).map(&:reverse).join.to_i.then.to_a.pack('U')
<rubydoc> # => "☕" (https://carc.in/#/r/9xyn)
<havenwood> &>> 42.then.to_a
<rubydoc> # => [42] (https://carc.in/#/r/9xyo)
<burgestrand> TIL Integer#digits
<havenwood> &>> 420.digits(2)
<rubydoc> # => [0, 0, 1, 0, 0, 1, 0, 1, 1] (https://carc.in/#/r/9xyp)
baojg has quit [Remote host closed the connection]
<havenwood> &>> 255.digits(16)
<rubydoc> # => [15, 15] (https://carc.in/#/r/9xyq)
baojg has joined #ruby
<nakilon> &>> ('a'.ord.to_s + '1'.ord.to_s).to_i.chr(Encoding::UTF_8)
<rubydoc> # => "☕" (https://carc.in/#/r/9xys)
<havenwood> burgestrand: And opposite direction from Elixir's digits.
<nakilon> idk why you did .chars
vondruch has quit [Quit: vondruch]
<havenwood> nakilon: Pre coffee.
<havenwood> I have the cup now, just no effect until I drink.
vondruch has joined #ruby
<havenwood> &>> 12345.digits.each_with_index.reduce(0) { |acc, (n, i)| acc + n * 10 ** i }
<rubydoc> # => 12345 (https://carc.in/#/r/9xyt)
<burgestrand> havenwood yeah, I must admit, the order of digits surprised be a bit.
<havenwood> &>> 12345.digits
<rubydoc> # => [5, 4, 3, 2, 1] (https://carc.in/#/r/9xyu)
<havenwood> &>> 12345.digits.each_with_index.to_h { [10 ** _2, _1] }
<rubydoc> # => {1=>5, 10=>4, 100=>3, 1000=>2, 10000=>1} (https://carc.in/#/r/9xyv)
Emmanuel_Chanel has joined #ruby
<burgestrand> Huh, yeah, no mention of why it's little endian https://bugs.ruby-lang.org/issues/12447 — ah well, what's surprising to me is obvious to somebody else :)
infinityfye has quit [Ping timeout: 256 seconds]
infinityfye has joined #ruby
<nakilon> &>> (("☕".ord + 10) * 13 + 999).chr(Encoding::UTF_8)
<rubydoc> # => "🍺" (https://carc.in/#/r/9xyy)
emptyflask has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 260 seconds]
ta has joined #ruby
openstruct has joined #ruby
openstruct has quit [Changing host]
openstruct has joined #ruby
openstruct has quit [Client Quit]
MadLamb has quit [Read error: No route to host]
Rudd0 has joined #ruby
emptyflask has quit [Ping timeout: 256 seconds]
<nakilon> &>> ("c0ffee".hex / 100 + "21012".to_i("101".to_i(RUBY_VERSION.to_s.to_i))).chr(Encoding::UTF_8)
<rubydoc> # => "🍺" (https://carc.in/#/r/9xzh)
orbyt_ has joined #ruby
emptyflask has joined #ruby
DaRock has quit [Ping timeout: 240 seconds]
<fippy> &>> 10.times.reduce([1,1]) {|seq,_| seq.push seq.last(2).sum}
<rubydoc> # => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144] (https://carc.in/#/r/9xzv)
bmurt has joined #ruby
cthulchu_ has joined #ruby
Glumetu has quit [Quit: Glumetu]
lanky_leguan has joined #ruby
Emmanuel_Chanel has joined #ruby
dionysus69 has quit [Quit: dionysus69]
Iarfen has joined #ruby
dionysus69 has joined #ruby
<proc> got a strange but where the command "bundler" works fine, but the command "bundle" shows a command not found error. was working before, haven't changed anything
<proc> using rbenv (ran their health check script, seems to say all is okay)
<proc> any ideas?
<nakilon> this colorful irb of 2.7 is buggy
<nakilon> it eats the last character on the line in macOS Terminal
chouhoulis has joined #ruby
lanky_leguan has quit [Quit: pro quo]
burgestrand has quit [Quit: burgestrand]
<proc> ah fixed, the rbenv rehash was stuck, apparently
fercell has quit [Ping timeout: 264 seconds]
burgestrand has joined #ruby
siaw23 has quit [Quit: Textual IRC Client: www.textualapp.com]
burgestrand has quit [Client Quit]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
charrit69 has quit [Quit: Konversation terminated!]
baojg has quit [Remote host closed the connection]
orbyt_ has joined #ruby
baojg has joined #ruby
adaedra has joined #ruby
<adaedra> hi
<jhass> hey, long time no see again :)
<adaedra> indeed
TCZ has quit [Quit: Leaving]
<jhass> how's it going?
<adaedra> it's going
<jhass> better than not!
TomyWork has joined #ruby
<adaedra> indeed
<adaedra> what about you?
<jhass> not bad, switching jobs end of year :)
zacts has joined #ruby
<jhass> no more android, all ruby <3
<adaedra> ooh
<adaedra> hope it goes well for you
<jhass> me too :D
<adaedra> Looking for one myself, but Corona is making things hard
<jhass> maybe someone here has some hints :) I can recommend you to anybody fwiw :D
<adaedra> that's very nice of you
mjacob has joined #ruby
chamunks has quit [Quit: Don't worry I'm not gone yet.]
gix has joined #ruby
stryek has quit [Quit: Connection closed for inactivity]
Eiam has joined #ruby
<mjacob> is there a library to define "data classes" in a way that doesn't require inheriting from some class (including a module is okay), supports making the objects "immutable", and automatically makes the objects hashable?
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass> other than immutable, Struct strikes off that list pretty well
<jhass> >> Foo = Struct.new(:bar); Foo.new(0).to_h
<jhass> &>> Foo = Struct.new(:bar); Foo.new(0).to_h
* jhass hits rubydoc
<jhass> so if you were to call .freeze on the new objects manually or by overriding initialize, it's also immutable
<mjacob> jhass: i forgot one requirement: it should not default missing parameters to nil
rubydoc has quit [Ping timeout: 256 seconds]
<jhass> mmh, then I'm out :D
phaul has quit [Ping timeout: 246 seconds]
<adam12> Could probably build something with adamantium and equalizer gems, but in reality I'd _personally_ just use dry-struct.
<jhass> ^
<mjacob> with Struct i also have the problem that there seems to be no way to make it work in a subclass of another class
burgestrand has joined #ruby
<jhass> or I mean handroll your own Struct/dry-struct like thing, it's not that complicated
burgestrand has quit [Client Quit]
phaul has joined #ruby
<mjacob> adam12: dry-struct looks mostly good, but there seems to be no way to use it without subclassing something
<adam12> mjacob: Right; it's probably the only thing on your list that it doesn't meet.
rubydoc has joined #ruby
<adam12> mjacob: There's others if you look. I think Tom Dalling has one called ValueSemantics.
tcrypt has joined #ruby
<adam12> mjacob: What's the opposition of inheritance? Trying to prefer composition of some sort?
chamunks has joined #ruby
<mjacob> adam12: a minor annoyance is the extra class in the inheritance hierachy. a bigger issue is that having to inherit makes it impossible to use it with something that already has to inherit from something
silverdust has quit [Ping timeout: 272 seconds]
<mjacob> adam12: ValueSemantics seems very close to what i want, thank y ou
<adam12> mjacob: yw
TomyWork has quit [Quit: Leaving]
Eiam has quit [Read error: Connection reset by peer]
Eiam has joined #ruby
maleghast has quit [Quit: Leaving]
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
vondruch has quit [Read error: Connection reset by peer]
zacts has quit [Quit: leaving]
greengriminal has quit [Quit: Leaving]
kristian_on_linu has joined #ruby
bocaneri has quit [Remote host closed the connection]
emptyflask has quit [Ping timeout: 256 seconds]
emptyflask has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vondruch has joined #ruby
imode has joined #ruby
TCZ has joined #ruby
vondruch has quit [Ping timeout: 246 seconds]
phaul has quit [Ping timeout: 256 seconds]
rubydoc has quit [Ping timeout: 256 seconds]
phaul has joined #ruby
rubydoc has joined #ruby
rippa has joined #ruby
<riceandbeans> is rescue nil functionally the same as just rescue
baojg has quit [Remote host closed the connection]
<jhass> just rescue is a syntax error, no?
<adam12> riceandbeans: you're comparing a rescue modifier vs a rescue block?
baojg has joined #ruby
<adam12> riceandbeans: ie. something rescue nil vs begin; rescue; end
<riceandbeans> one sec
<adam12> riceandbeans: rescue nil would be a syntax error.
<adam12> riceandbeans: Right now there's an implicit argument to rescue, and it's StandardError
<adam12> I say argument but rescue is a special case.
<riceandbeans> But let's say this was within a module in a class
<riceandbeans> ANd you had a method in there
<riceandbeans> foo = bar.meth() rescue nil; return foo.nil?
<riceandbeans> In that case, would rescue not be the same as rescue nil
<adam12> riceandbeans: No. That's a rescue modifier and it's different.
<adam12> riceandbeans: It still does an implicit rescue of StandardError, and `nil` is the return value.
<adam12> Actually, I might be wrong about that being a StandardError rescue. I'd have to look.
<adam12> Generally bar.meth() rescue nil is bad form and considered a code smell.
<riceandbeans> Yeah, I thought it looked particularly....belh.
<riceandbeans> bleh rather
<adam12> Rescuing exceptions is generally suggested to be explicit. The modifier doesnt' accept a type of exception to rescue and can hide bugs.
<riceandbeans> I wanted to change it to bar.meth().nil? and make it one line
<adam12> what's wrong with bar.meth.nil?
<adam12> riceandbeans: show some real code. maybe a few lines around the method you're working with.
<riceandbeans> Don't know, it wasn't written that way lol
<riceandbeans> It's just a two line method, one that sets foo to output of a method and then another that returns a ternary
SeepingN has joined #ruby
emptyflask has quit [Quit: WeeChat 2.9]
<adam12> What's the ternary? I didn't see it here. Do you care about the return value of bar.meth?
<adam12> other than it not being nil?
<riceandbeans> the ternary is bar.meth.nil?
<riceandbeans> But it's just expressed as a separate line because...I have no idea
<adam12> what's the rest of the ternary?
<havenwood> riceandbeans: Show the code?
rubydoc has quit [Ping timeout: 260 seconds]
<riceandbeans> foo = bar.meth rescue nil; return foo.nil? ? false : true
phaul has quit [Ping timeout: 260 seconds]
<adam12> I wonder if there's a chance bar is nil.
<adam12> !bar&.meth.nil?
cd has joined #ruby
<riceandbeans> For this I would hope not, but meh
<havenwood> riceandbeans: Do you actually care if #meth returns `nil` versus `false`?
<riceandbeans> I just think some of this stuff looks really weird.
<riceandbeans> I'm just looking at another team's code and making sad faces
<havenwood> riceandbeans: !!bar&.meth
<havenwood> Exceptions should be exceptional cases. They're not nice for flow control.
<adam12> riceandbeans: true/false as return values in a ternary are often unnecessary, since you can just negate the conditional if necessary (or return the conditional if not necessaray).
<adam12> No mental gymnastics required.
<havenwood> riceandbeans: Which just makes it: bar&.meth
<adam12> The only question is whether bar can be nil. My guess is either that's the case or bar.meth is flakey and they'd rather just eat errors silently.
<riceandbeans> That sounds unfortunate
<riceandbeans> But why bar&.meth instead of bar.meth.nil?
<adam12> riceandbeans: This is the problem with the rescue modifier. There's no indication why it's there. Does meth fail? is bar sometimes nil?
<adam12> riceandbeans: In theory, bar.meth.nil? is fine, but nil.meth.nil? is NoMethodError.
<adam12> so bar&.meth.nil? get's you that nil safety.
vondruch has joined #ruby
<adam12> That said, I'd rather guard on bar being nil somewhere else maybe, but you work with what you have.
<riceandbeans> Yeah I'd rather deal with meth's response there and bar's problems where bar is created
phaul has joined #ruby
rubydoc has joined #ruby
<nakilon> &>> 'gxxfszr'.to_i(36).to_s(9).to_i.to_s(13).to_i(22).to_s(9).to_i.to_s(36)
<rubydoc> # => "havenwood" (https://carc.in/#/r/9y0n)
silverdust has joined #ruby
ur5us_ has joined #ruby
phaul has quit [Ping timeout: 256 seconds]
adaedra has quit [Quit: Textual IRC Client: www.textualapp.com]
rubydoc has quit [Ping timeout: 256 seconds]
Retropikzel has quit [Quit: Vision[0.10.3]: i've been blurred!]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
Retropikzel has joined #ruby
siloxid has joined #ruby
rubydoc has joined #ruby
rubydoc has quit [Excess Flood]
rubydoc has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
rubydoc has quit [Ping timeout: 256 seconds]
wmoxam has quit [Ping timeout: 272 seconds]
phaul has joined #ruby
phaul has quit [Ping timeout: 256 seconds]
phaul has joined #ruby
rubydoc has joined #ruby
wmoxam has joined #ruby
MuffinPimp has quit [Quit: Goodbye.]
rubydoc has quit [Excess Flood]
MuffinPimp has joined #ruby
rubydoc has joined #ruby
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
kristian_on_linu has quit [Read error: Connection reset by peer]
phaul has quit [Ping timeout: 260 seconds]
rubydoc has quit [Ping timeout: 258 seconds]
bmurt has joined #ruby
<cloud69> Hey! Anyone know why I'm getting `LoadError: cannot load such file -- pry` despite `gem list | grep pry` shows `pry (0.13.1)`?
<riceandbeans> What would be the most Ruby way to say, if foo == bar || foo == baz
silverdust has quit [Ping timeout: 265 seconds]
<leftylink> I believe if foo == bar || foo == baz is the most Ruby way to say it. the alternative soem would consider is [bar, baz].include?(foo), but this doesn't seem useful unless there are more elements in that array
<nakilon> does Ruby 3.0 provide any better form of: .find{ |_| not _.empty? }
TCZ has quit [Quit: Leaving]
<balo> nakilon: .find(&:any?) ?
<leftylink> if we are guaranteed the list doesn't contain a nil or a false, we could already do find(&:any?), but I don't like it because I don't like it when people assume that #any? is the opposite of #empty?
<leftylink> oh... beaten to the punch
<leftylink> dang
<havenwood> nakilon: balo's suggestion is good for any modern Ruby
rubydoc has joined #ruby
<balo> [nil].any? => false , just like [nil].empty?
<balo> ahh, okay, got it now
<balo> yeah, leftylink is right, could be tricky
<leftylink> probably the way to go here is to refine an #nonempty? onto an array, or refine find_not onto enumerable
<havenwood> Then again, are you really wanting to check if there are nils in a collection?
<havenwood> Probably something more substantive. Probably.
<nakilon> why not
<havenwood> nakilon: You can. Just most often aren't.
<nakilon> empty collection and collection with nils are definitely different things
<nakilon> idk where you take this "most often" from )
<leftylink> there's also lazy.reject(&:empty?).first, but how unfortunate that we have to add lazy and first just to get this
baojg has quit [Remote host closed the connection]
<nakilon> ah, I see your point, the .empty? on nil would cause exception
<havenwood> nakilon: The "most often" is from it most often being the case that there aren't Arrays of nils and falses when checking for emptiness.
<havenwood> There are rarely, but not usually.
<leftylink> oh right, the video I wan't isn't searchable by normal methods... I was going to reference the "correct! nil! wat?" video
baojg has joined #ruby
phaul has joined #ruby
<nakilon> any? will just do more work
<nakilon> I don't want to check the content on falseness, I want to ask the array whether it's empty or not
<havenwood> nakilon: find { !_1.empty? }
<nakilon> omg
<havenwood> nakilon: ;)
<havenwood> !_1 looks like a coffee cup
<havenwood> or something
<havenwood> a train depot?
<nakilon> now imagine code with { |_| and { !_1 everywhere
<nakilon> like a pain for someone with weak eyes
<leftylink> it's too bad. making _ unassignable would deal with some problems, but then irb would have to do some unusual things
<leftylink> I would have liked to make _ unassignable-to, really, but not my choice to make
rubydoc has quit [Ping timeout: 246 seconds]
phaul has quit [Ping timeout: 256 seconds]
<havenwood> nakilon: syntax highlighting to the rescue
<nakilon> idk how _1, _2, _3 can be considered fine in the same time with _ to be not
<leftylink> ideally they should all have been unassignable-to as well
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<leftylink> again another time where it's too bad I don't get to make the decisions
phaul has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
rubydoc has joined #ruby
<havenwood> just use ‗
<havenwood> &>> ‗1 = :phew
<leftylink> maybe it's time to make my new language
<havenwood> leftylink: Just make a "precompiler" for Ruby.
<rubydoc> # => :phew (https://carc.in/#/r/9y1j)
<havenwood> leftylink: Or pull a Crystal and write a compiler in Ruby before you bootstrap.
phaul has quit [Ping timeout: 240 seconds]
silverdust has joined #ruby
rubydoc has quit [Ping timeout: 260 seconds]
* nakilon is making a two-level lazily sorted data structure _Oo
orbyt_ has joined #ruby
rubydoc has joined #ruby
phaul has joined #ruby
dionysus70 has joined #ruby
dionysus69 has quit [Ping timeout: 246 seconds]
dionysus70 is now known as dionysus69
<nakilon> it's actually nor the first time I want Array to have an attribute .sorted?
<nakilon> *not
phaul has quit [Ping timeout: 246 seconds]
rubydoc has quit [Ping timeout: 260 seconds]
baojg has quit [Remote host closed the connection]
<nakilon> that would be automatically set to true after a call of .sort! or .sort_by! and unset on .push and .unshift
<nakilon> (forget about .sort_by!)
baojg has joined #ruby
<apotheon> I've obviously been writing too much C lately. I sometimes forget about convenient Ruby constructs that used to be second nature.
<apotheon> . . . but C is my favorite video game, so I don't regret it at all.
phaul has joined #ruby
rubydoc has joined #ruby
<havenwood> nakilon: but different
impermanence has joined #ruby
<nakilon> does carc.in say "There was no output." if it took too long to compute?
<nakilon> havenwood look like an array that is always sorted
<nakilon> in my case I need to delay the sorting
phaul has quit [Ping timeout: 256 seconds]
rubydoc has quit [Ping timeout: 272 seconds]
<nakilon> meh, ideone also can't run longer than 5 seconds
TCZ has joined #ruby
braincrash has joined #ruby
rubydoc has joined #ruby
LtHummus has quit [Quit: ZNC 1.8.2 - https://znc.in]
rubydoc has quit [Ping timeout: 256 seconds]
LtHummus has joined #ruby
siloxid has quit [Ping timeout: 264 seconds]
silverdust has quit [Ping timeout: 264 seconds]
silverdust has joined #ruby
silverdust has quit [Ping timeout: 264 seconds]
baojg has quit [Remote host closed the connection]
baojg has joined #ruby
rubydoc has joined #ruby
Iarfen has quit [Remote host closed the connection]
<cloud69> At line 40 of my Newegg scraper: https://pastebin.com/FQUdwiA6 - how come `products_list << page` doesn't write anything to `products_list` despite `page` not being empty?
<cloud69> Wait nevermind.
phaul has joined #ruby
<cloud69> pretty cool scraper tho amiright? :)
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
infinityfye has quit [Quit: Leaving]