kristian_on_linu has quit [Remote host closed the connection]
TCZ has joined #ruby
roadie has joined #ruby
<leitz>
sagax, doesn't an "if" or "unless" cover that?
<leitz>
I'm for fewer keywords, myself. Not too few, though. This isn't Go.
olddogbarks has quit [Ping timeout: 252 seconds]
<sagax>
i can `value == nil` or `value == true` or `value == false` but i looking for better way. we have `value.nil?` and maybe we have some like as `true?` or `false?`
roadie has quit [Ping timeout: 260 seconds]
dandaman has joined #ruby
olddogbarks has joined #ruby
<dandaman>
what's the difference between these two syntaxes? my_object['some_key'] vs my_object[:some_key]
<sagax>
'some_key' it's string, :some_key it's symbol
<sagax>
f = {:a => 1, 'a' => 2} --> f[:a] --> 1 and f['a'] --> 2
<sagax>
it's not just syntax
<dandaman>
what's the difference between making the key a symbol vs a string?
<havenwood>
dandaman: A String is regular text data. A Symbol is a label with a text name.
<sagax>
not different, for key you can use something like as f = {:a => 1, 'a' => 2, 3 => 4}
<sagax>
string, symbol, number
<havenwood>
dandaman: Symbols tend to make great Hash keys, so they got syntactic sugar so `{aim: true}` is the same as `{:aim => true`}, like sagax said.
<dandaman>
got it, so is there any reason to use one over the other?
<dandaman>
havenwood: why do they make great hash keys
<dandaman>
?
<havenwood>
dandaman: They are frozen by default, so no mutation possibility and they have a handy syntax with Hashes.
<havenwood>
dandaman: You'll know when you need a String, typically.
<dandaman>
wouldnt a string be frozen by default too? like you can't really change the key in an objectm right? can you give me an example of when i'd want a string vs a symbol as the key?
<dandaman>
"like you can't really change the key in an objectm right?" by that i mean, if you change the key you're basically just moving the value to a different "place"
<adam12>
xco: I don't have a 100% correct answer for you other than maybe bundler captures the messages and displays them at the end, and that's what you're used to.
<xco>
adam12 i'd expect for bundler to display the post-install msg last ideally... it's not doing that for some reason.
<adam12>
xco: The example you shared shows you installing with `gem`, not `bundle`
<xco>
adam12 right... so i've i'm using `gem` is there a way to make the install msg come last?
<xco>
that's helpful, i think the behaviour i'm after should be hackable... i'll keep playing with it until something comes up
<adam12>
xco: Not sure how your tool is used but if it's a binary/script maybe you could have a message that is displayed on first run.
<xco>
adam12 it's just a CLI, you type commands to it for an output
<xco>
everything happens in the shell
caterfxo has quit [Ping timeout: 264 seconds]
<adam12>
xco: Maybe try the message bit. Just track that you've displayed it to the user somehow (writing to the XDG config directory for your script or something).
<adam12>
xco: Or put it in the help message for your script. Or have an `--about` flag or something.
<xco>
adam12 that'll be a good idea too
roadie has joined #ruby
sergioro has joined #ruby
jidar has quit [Quit: WeeChat 2.8]
roadie has quit [Ping timeout: 258 seconds]
jinmiaoluo has joined #ruby
jidar_ has joined #ruby
jidar_ has quit [Client Quit]
jidar has joined #ruby
jidar has quit [Client Quit]
jidar has joined #ruby
duderonomy has joined #ruby
<havenwood>
dandaman: When a String is used as a key, Ruby duplicates, then freezes it, leaving the original untouched. This works, but creates a duplicates object with the corresponding memory usage and pressure on the GC.
<havenwood>
dandaman: A Symbol is mean to be a label, which is exactly what a key is, so they align nicely.
<havenwood>
dandaman: A Symbol key doesn't need to be duplicated or frozen, and can just be used directly without fuss.
<dandaman>
ahhh i see
<havenwood>
dandaman: As the Hash docs mention, "a String passed as a key will be duplicated and frozen."
<dandaman>
so when would it ever make sense to use a string as a key?
<dandaman>
why not just build the language in a way where all keys are interpretted as symbols, even if you pass in a string
<havenwood>
dandaman: Ruby allows many ways to do a thing, but tries to make the right way the most beautiful. Here, the syntactic sugar with Symbols guides you to the best key form for a text label.
<havenwood>
{aim: true}
<havenwood>
is prettier than
alfiemax has joined #ruby
<havenwood>
{"aim" => true}
<havenwood>
You can see through it without inclusions.
<dandaman>
can't deny the asthetics of the former… just wondering if there's any usecase for the latter
<havenwood>
dandaman: There aren't a ton of usecases. It's more common to see an Integer key.
<havenwood>
dandaman: Symbols are basically Integers with a text label.
roadie has joined #ruby
<dandaman>
hmm, alright. thanks for taking the time to explain it all to me. The fact that it's possible to use strings still bothers me a little bit but at least i now the proper way of doing things!
<dandaman>
now know*
<havenwood>
dandaman: It used to be that Symbols were never garbage collected and Strings were usually mutable. These days they've converged somewhat since Symbols *are* GCed and Strings literals can be frozen by default with a magic comment.
<havenwood>
dandaman: No prob, any time.
alfiemax has quit [Ping timeout: 256 seconds]
dandaman has quit [Quit: Leaving.]
roadie has quit [Ping timeout: 240 seconds]
ChmEarl has quit [Quit: Leaving]
Esa__ has quit []
jinmiaoluo has quit [Ping timeout: 256 seconds]
alfiemax has joined #ruby
jinmiaoluo has joined #ruby
roadie has joined #ruby
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
chalkmonster has joined #ruby
gix has quit [Disconnected by services]
dandaman has joined #ruby
roadie has quit [Ping timeout: 256 seconds]
jinmiaoluo has quit [Ping timeout: 256 seconds]
troulouliou_div2 has quit [Ping timeout: 256 seconds]
jinmiaoluo has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.8]
troulouliou_div2 has joined #ruby
troulouliou_dev has joined #ruby
chalkmonster has joined #ruby
jinmiaoluo has quit [Quit: WeeChat 2.8]
chalkmonster has quit [Client Quit]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<siery>
al2o3-cr: Ya, thank you, that's what I been looking for
<al2o3-cr>
siery: np ;)
<jhass>
heh that bot shouldn't use the target for the error message :D
<jhass>
phaul: ^ (iirc)
<phaul>
jhass: yeah it's a bit clunky, hard to use because you need to get the receiver right. I was thinking how to make it better but couldn't come up with a better solution. We could supress the error message to make it less noisy.
<phaul>
Or in case mulitple receivers respond to a method we could just chose the first
<jhass>
I meant if I do &ri something phaul it should say jhass: not found and not phaul: not found :)
<phaul>
ah, fair point
<phaul>
I'll fix that
<jhass>
<3
conta has joined #ruby
conta has quit [Client Quit]
TCZ has quit [Quit: Leaving]
licksjp has joined #ruby
<licksjp>
Hello
<al2o3-cr>
o/
<licksjp>
I am japanese
<licksjp>
I live in Japan
<al2o3-cr>
very nice ;)
<licksjp>
I have made the "姓名判断" program by ruby
<licksjp>
my PC is Mac
<licksjp>
my Ruby editor is Visual studio code
<pwnd_nsfw>
interesting mix lol
<CommunistWolf>
gedit is where it's at
<al2o3-cr>
nano for it's simplicity.
<pwnd_nsfw>
Notepad in a vm
<CommunistWolf>
acceptable, but I quite like mouse support
<al2o3-cr>
fair play.
<al2o3-cr>
CommunistWolf: alt + m enables mouse support in nano
<CommunistWolf>
oooh, magic
<al2o3-cr>
TIL
xco has joined #ruby
<pwnd_nsfw>
rifk
caterfxo has joined #ruby
Ai9zO5AP has joined #ruby
jinmiaoluo has quit [Remote host closed the connection]
rubydoc has quit [Remote host closed the connection]
rubydoc has joined #ruby
jinmiaoluo has joined #ruby
<phaul>
&ri invalid, jhass
<rubydoc>
phaul: Found no entry that matches method invalid