2 ms·
The article is a bit confusing, but I like the concept behind symbols: Basically a way to distinguish identifier names (chosen by the programmer) from user-faci
by yccs27 11mo ago
The article is a bit confusing, but I like the concept behind symbols: Basically a way to distinguish identifier names (chosen by the programmer) from user-facing strings.
The distinction between is one I've mentally adopted in other languages like Python as well. For personal projects I like to use single quotes for 'symbols' and double quotes for "strings", e.g.:
add_label(text="Hello World!", align='center')
Does anyone else do something similar?
- wild_egg 11mo agoSingle vs double quotes is also semantically significant in Ruby. Double quoted strings support interpolation whereas single quoted does not.
- rubyfan 11mo agoI almost never use single quotes unless I’m in someone else’s code that already used single quotes. And then I have to fight the urge to not change everything to double quotes just because.
- masklinn 11mo ago> Does anyone else do something similar? I do exactly the same thing. Did you also derive it from Erlang?
- Fire-Dragon-DoL 11mo agoI have been with you for a very long time,until I recently realized how tricky the edge cases are, I cannot figure out a good rule. A json api, should it use symbols or strings? Json has string keys, but the api keys are chosen by the programmer. I can't remember which edgecase,but there are another bunch I found that are tricky.