PPlamenu
HomeTrendingLive feedsPeopleGroupsRulesStaff
Sign in
PPlamenu
HomeTrendingLive feedsPeopleGroupsRulesStaff
Sign in
Shane Becker@veganstraightedge@ruby.social
⁨22⁩d

Here’s a wacky #Ruby idea…

What if only symbols for hash keys?

How much code would that break?
How much of that is actually non-symbol-able?

I.e.

{ “Shane Becker” => “veganstraightedge” }

1000
Open original page
BoostsQuotesFavs
Andrew Nesbitt@andrewnez@mastodon.social
⁨22⁩d

Replying to @⁨veganstraightedge@ruby.social⁩

@veganstraightedge :"test test" is a symbol, would you just end up with some to_sym under the hood?

1000
Open original page
BoostsQuotesFavs
Shane Becker@veganstraightedge@ruby.social
⁨22⁩d

Replying to @⁨andrewnez@mastodon.social⁩

@andrewnez in this wacky hypothetical… that'd not be a valid legal symbol

only symbol safe names could be symbol keys

azAZ09_

(like a hashtag)

¯\_(ツ)_/¯

1000
Open original page
BoostsQuotesFavs
Andrew Nesbitt@andrewnez@mastodon.social
⁨22⁩d

Replying to @⁨veganstraightedge@ruby.social⁩

@veganstraightedge oh I get you, I’m a fan, the only thing that would break for me is using them mechanically as autogenerated dictionaries

1000
Open original page
BoostsQuotesFavs
Shane Becker@veganstraightedge@ruby.social
⁨22⁩d

Replying to @⁨andrewnez@mastodon.social⁩

@andrewnez say more about that pls?

⁨Jul⁩ ⁨24⁩, ⁨2026⁩, ⁨04:36⁩en
1000
Open original page
BoostsQuotesFavs
Andrew Nesbitt@andrewnez@mastodon.social
⁨22⁩d

Replying to @⁨veganstraightedge@ruby.social⁩

@veganstraightedge if I’m looping through a big dataset and incrementing counters for undefined number of strings, I use the string as the key in the hash with an initial value of zero, and increment from there. Then by the end I have a hash with string keys and int values

1000
Open original page
BoostsQuotesFavs
Shane Becker@veganstraightedge@ruby.social
⁨22⁩d

Replying to @⁨andrewnez@mastodon.social⁩

@andrewnez ah right. and sluggifying the string to symbol wouldn't work because it's not not roundtrippable, right?

"Shane Becker" #=> :shane_becker
"HTTP.rb" #=> :http_rb

0000
Open original page
BoostsQuotesFavs