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
bandithijo has joined #ruby
FetidToot3 has joined #ruby
FetidToot has quit [Ping timeout: 272 seconds]
FetidToot3 is now known as FetidToot
Rounin has quit [Ping timeout: 252 seconds]
ur5us has quit [Ping timeout: 240 seconds]
drincruz has joined #ruby
drincruz_ has quit [Ping timeout: 240 seconds]
bonhoeffer has joined #ruby
drincruz_ has joined #ruby
drincruz has quit [Ping timeout: 272 seconds]
khanred has joined #ruby
drincruz_ has quit [Ping timeout: 240 seconds]
bonhoeffer has quit [Ping timeout: 272 seconds]
gr33n7007h has quit [Ping timeout: 252 seconds]
khanred has left #ruby [Leaving]
ur5us has joined #ruby
gr33n7007h has joined #ruby
xall has quit [Quit: Client closed]
postmodern has quit [Quit: Leaving]
ur5us has quit [Ping timeout: 252 seconds]
ansimita has quit [Ping timeout: 240 seconds]
lunarkitty has joined #ruby
ecso has joined #ruby
sam113101 has quit [Ping timeout: 246 seconds]
sam113101 has joined #ruby
hexreel has joined #ruby
Garb0 has joined #ruby
congratulated has quit [Ping timeout: 246 seconds]
congratulated has joined #ruby
crawler has joined #ruby
_ht has joined #ruby
sam113102 has joined #ruby
teclator has joined #ruby
sam113101 has quit [Ping timeout: 255 seconds]
sam113102 is now known as sam113101
rhett has joined #ruby
rhett has quit [Excess Flood]
lunarkitty has quit [Quit: Connection closed for inactivity]
hexreel has quit [Quit: nyaa~]
ur5us has joined #ruby
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
Garb0 has quit [Quit: Garb0]
sagax has joined #ruby
<sagax> hi all
<sagax> why ruby not have just Boolean class?
<nakilon> why should it?
<wnd> you can always create your own (and include support for FILE_NOT_FOUND) :-)
<nakilon> though idk
<sagax> because can be require `true` or `false` state
<sagax> not only `true` or only `false`
<nakilon> what is require stat?
niv has quit [Quit: Powered by LunarBNC: https://LunarBNC.net]
<sagax> example if Boolean; something; end
<wnd> &>> [true, 1, '', 0, false, nil].map { |x| x ? true : false }
<wnd> oh
<wnd> in short, false and nil and falsey. everything (afaik) is truthy
<wnd> s/everything/& else/
<nakilon> ideally it sucks to build ifs around multiple types
<nakilon> especially such as these
niv has joined #ruby
ur5us has quit [Quit: Leaving]
ur5us has joined #ruby
Garb0 has joined #ruby
<jhass[m]> case foo; when String; ...; when true, false; ...; end; not too bad IMO :P
Garb0 has quit [Ping timeout: 272 seconds]
yosafbridge has quit [Quit: Leaving]
yosafbridge has joined #ruby
RougeR has joined #ruby
Garb0 has joined #ruby
Rounin has joined #ruby
Garb0 has quit [Ping timeout: 252 seconds]
Garb0 has joined #ruby
Garb0 has quit [Ping timeout: 252 seconds]
ur5us has quit [Ping timeout: 246 seconds]
molle has joined #ruby
mollerup has quit [Ping timeout: 252 seconds]
peder has quit [Remote host closed the connection]
<leah2> sagax: mruby has one ;)
gr33n7007h has quit [Quit: WeeChat 3.2]
peder has joined #ruby
crawler has quit [Remote host closed the connection]
gr33n7007h has joined #ruby
<leah2> ofc you can do something like https://l2.re/19sOPo
jhawthorn_ has quit [Ping timeout: 258 seconds]
jhawthorn has joined #ruby
crawler has joined #ruby
niv has quit [Ping timeout: 252 seconds]
Rounin has quit [Ping timeout: 252 seconds]
gr33n7007h has quit [Ping timeout: 246 seconds]
gr33n7007h has joined #ruby
niv has joined #ruby
Garb0 has joined #ruby
Garb00 has joined #ruby
Garb0 has quit [Ping timeout: 255 seconds]
bonhoeffer has joined #ruby
Garb00 has quit [Quit: Garb00]
Garb0 has joined #ruby
<rg> interesting
drincruz_ has joined #ruby
<adam12> The `Boolean` class discussion has been going on since ~ 2006 or even earlier. Here's a recent-ish thread on it: https://bugs.ruby-lang.org/issues/12515
<adam12> I can see the arguments against it, but also the benefits. I know the core team is a bit shy on adding new classes, but a Boolean superclass, a class to represent Time duration, and maybe even a result class would probably go a long way. Oh well.
drincruz_ has quit [Ping timeout: 265 seconds]
<leah2> instead of silly stuff like => assignment :p
ignorand has joined #ruby
royo25 has joined #ruby
bonhoeffer has quit [Remote host closed the connection]
bonhoeffer has joined #ruby
drincruz_ has joined #ruby
<adam12> They had to add a special case for boolean to RBS, so it should probably have been done then :|
drincruz_ has quit [Ping timeout: 252 seconds]
Garb00 has joined #ruby
nolesswrong has quit [Ping timeout: 252 seconds]
Garb0 has quit [Remote host closed the connection]
gearnode has quit [Ping timeout: 252 seconds]
gr33n7007h has quit [Ping timeout: 252 seconds]
gearnode has joined #ruby
infernix has quit [Quit: ZNC - http://znc.sourceforge.net]
nolesswrong has joined #ruby
jhawthorn has quit [Quit: ZNC 1.8.2 - https://znc.in]
gr33n7007h has joined #ruby
jhawthorn has joined #ruby
bonhoeffer has quit [Read error: Connection reset by peer]
infernix has joined #ruby
drincruz_ has joined #ruby
finsternis has quit [Remote host closed the connection]
ansimita has joined #ruby
Garb00 has quit [Quit: Garb00]
BSaboia has joined #ruby
<rg> interesting how matz rejected that issue but added it to mruby later on?
swaggboi has quit [Ping timeout: 246 seconds]
<adam12> rg: Indeed :P
<leah2> yeah ruby 3 would have been a good option to break that :p
royo25 has quit [Quit: Bye]
BSaboia has quit [Quit: This computer has gone to sleep]
BSaboia has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
drincruz_ has quit [Ping timeout: 272 seconds]
BSaboia has joined #ruby
weaksauce has joined #ruby
Rounin has joined #ruby
<ignorand> I have class methods which connect to aws s3.
bandithijo has quit [Ping timeout: 255 seconds]
<ignorand> would it be best to make my client be a class variable? No need to 'connect/disconnect' for every call right?
<ignorand> also, not sure how to 'close' the client
<ignorand> I would think something like ```@@s3 = Aws::S3::Client.new if @@s3.nil?```
orbyt has joined #ruby
<adam12> ignorand: Unless you absolutely know what you're doing, avoid class variables (@@something) almost always.
<adam12> ignorand: You're better off assigning it to a constant. Client = Aws::S3::Client.new
<ignorand> adam12, okay, so avoiding it since I dont know :P
<adam12> ignorand: If you need to "close" the client, you probably dont' want to assign it to a constant.
<ignorand> adam12, but since I do self.def myfunction do I have to do client = Aws::S3::Client.new in every function?
<adam12> ignorand: Can you show more code? Maybe give us a better idea.
<adam12> Does Aws::S3::Client.new ever take args?
<ignorand> adam12, https://dpaste.org/hmfR
<ignorand> adam12, no args in my case
<adam12> ignorand: Class variables look almost right on the surface, but they have strange effects in many cases that can be hard to debug.
<adam12> ignorand: You could use a class instance variable, which is similar. def self.client; @client ||= Aws::S3::Client.new; end;. Then just call `client` where you need it.
<adam12> The ||= syntax if you're not aware is an or-equals, and is a simple way to memoize some values. In this case, on the first call to `client`, it will assign to @client and return the value. Further calls to `client` just return the same value.
<adam12> I'm not sure what closing an s3 client would do. It might not matter to close it.
<ignorand> adam12, thanks
<ignorand> lemme try this :)
<ignorand> and what do I do if I want a constant string
<adam12> Foobar = "constant string"
<ignorand> and this will also be available for self.functions?
<adam12> Actually, I'd probably call it FOOBAR in this case, but anything starting with a capital letter is a constant.
<adam12> Yes.
<ignorand> and I can just place it under private right?
<ignorand> since it's only avail for the class
<adam12> ignorand: Trick question. Yes it can go under `private`, but no it has no effect on the visibility of the constant.
<ignorand> oow, lol
<adam12> ignorand: you'd need to call `private_constant` with the name of the constant to make it private.
<adam12> ignorand: the private, public, and protected statements only affect _methods_ in that class.
<ignorand> adam12, as long as it can't be changed it shouldnt matter :)
<adam12> ignorand: If it's a string, freeze it. Ruby will complain if you re-assign constants, so that can help.
<adam12> but there's nothign saying it will never change :P
<adam12> bbl. lunch.
<ignorand> yup: BUCKETNAME = 's3bucketforshorturls'.freeze
AriT93 has quit [Remote host closed the connection]
RougeR has quit [Remote host closed the connection]
RougeR has joined #ruby
<rg> private_constant wasn't for everybody when it arrived but in the end i think it upheld the spirit of ruby and how private doesn't strictly disallow access.
rg has quit [Quit: Leaving]
rg has joined #ruby
Ziyan has joined #ruby
<Ziyan> I got a question about Ruby style. When we assign a chained method call to a variable (ex: variable = User.where(...).where(...))` do we align it 2 spaces from 'variable' or 2 spaces from 'User'. (https://gist.github.com/ziyan-junaideen/981f13f36a976390c4ee14a17ab8f060)
<adam12> Ziyan: I usually to the first. But I'd actually put `User` on it's own line too.
<Ziyan> adam12 that is a good idea, never tried it... didn't know it was even legal :D
<leftylink> well. I prefer 2 spaces from variable, because 2 spaces from User is too much indentation. were I younger I'd even say "think of the bytes", but I guess these days people don't care about the bytes
<leftylink> oh, to be young again...
<adam12> Ziyan: I prefer it to indicate the line continues. For some reason `=` stands out more to me.
<adam12> Ziyan: Similar to leading periods (vs trailing periods)
menace has joined #ruby
menace has quit [Changing host]
menace has joined #ruby
menace is now known as Deknos
<Ziyan> leftylink true that... i actually got this from a very new Ruby developer. We were having a discussion about the Ruby style guide on multi line chaining. He was not buying it. And he says a line should be 120 in width. I was like what do you do if your variable name is 120 chars long. May be its easier on the eye having it in the same vertical point but I prefer not to have neck or eye strain 🤭. May be I am a little old.
<weaksauce> if your variable name is 120 characters you have a bigger problem
<adam12> I wonder if there's a limit to ruby variable name sizes...
<Ziyan> adam12 yah, i am personally in to leading. I guess you are a trailing guy? It took me a lot of effort to get accept CoffeeScript objects definition ending with an equal `data =\n blah: 123`. I am still not sure my brain agrees with it. I wonder how TypeScript is with Rails 6.
<adam12> Ziyan: No. Leading.
<adam12> Ziyan: Which is why I was thankful when IRB received support for leading . in paste :)
<adam12> I write very little Javascript since I agressively use Unpoly everywhere, so no comment :)
<adam12> I can see how my comment about the trailing period could be misconstrued tho.
pgib has joined #ruby
<Ziyan> weaksauce yah, i was just trying to make a point. to highlight a conflict in his logic. my variable names are a little long, but not that long. I am like `User.each_with_index { |user, index| blah(user, index) }. Ruby for me is about English.
insolentworm has joined #ruby
<Ziyan> adam12 variable name length is an intersting question. Need to dig in to that. never actually thought if it could be a probelm.
<adam12> >> eval("#{1_000_000.times.map { "A" }.join} = true")
<adam12> ruby[bot]: ohai
<Ziyan> adam12 i had to run it to confirm :D
<adam12> Ziyan: I didn't bother testing with longer. :P
<adam12> I don't want to crash my machine right now.
<adam12> But I guess there's a theoretical limit somewhere.
<gr33n7007h> probably until you run out of memory :p
<adam12> gr33n7007h: I was thinking maybe something in racc about parsing labels.. but memory might be first :P
<Ziyan> gr33n7007h yes I saw some articles saying there is no limit.
<Ziyan> adam12 weaksauce leftylink gr33n7007h : nice chatting. its almost midnight in Sri Lanka and i am runnin on UPS because of a storm. I will log out for the day. good day to you guys.
<adam12> Ziyan: cheers.
Ziyan has quit [Quit: Textual IRC Client: www.textualapp.com]
gr33n7007h has quit [Read error: Connection reset by peer]
gr33n7007h has joined #ruby
insolentworm has quit [Quit: WeeChat 3.2]
insolentworm has joined #ruby
insolentworm has quit [Client Quit]
insolentworm has joined #ruby
xeel has joined #ruby
lunarkitty has joined #ruby
ignorand has quit [Ping timeout: 268 seconds]
ignorand has joined #ruby
isekaijin has quit [Ping timeout: 252 seconds]
ignorand has quit [Ping timeout: 252 seconds]
isekaijin has joined #ruby
_ht has quit [Remote host closed the connection]
RougeR has quit [Remote host closed the connection]
reset has joined #ruby
xeel has quit [Quit: nyaa~]
xuochi has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
xuochi has quit [Quit: leaving]
xuochi has joined #ruby
xuochi has quit [Client Quit]
xuochi has joined #ruby
Deknos has quit [Quit: Deknos]
ur5us has joined #ruby
darkxploit has joined #ruby
ignorand has joined #ruby
curdlesnoot has joined #ruby
orbyt has quit [Quit: Textual IRC Client: www.textualapp.com]
bandithijo has joined #ruby
<ignorand> o/
<ignorand> anyone using aws-lamda with ruby?
orbyt has joined #ruby
sphex has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 240 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
molle has quit [Quit: Leaving]
BSaboia has joined #ruby
swaggboi has joined #ruby
lunarkitty has quit [Quit: Connection closed for inactivity]
Guest0 has joined #ruby
Guest0 has quit [Client Quit]
AriT93 has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
BSaboia has joined #ruby
BSaboia has quit [Ping timeout: 265 seconds]
pioto has joined #ruby
orbyt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
drincruz_ has joined #ruby
drincruz_ has quit [Ping timeout: 252 seconds]
graywolf has joined #ruby