<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]
<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.
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.
<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.