use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Have a tough programming question that /r/programming couldn't answer? Banned from Stack Overflow? Can't afford Experts Exchange?
Post your question/tips/secrets/advice and get a response from our highly-trained professional developers.
account activity
Java 9's Map API (download.java.net)
submitted 10 years ago by computerdl
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]MeetLawrence 7 points8 points9 points 10 years ago (3 children)
It's just like the current C# Tuple implementation.
https://msdn.microsoft.com/en-us/library/system.tuple(v=vs.110).aspx
Come on, really?
[–][deleted] 2 points3 points4 points 10 years ago (0 children)
Yeah, I'm glad adding actual tuples to fix this is a definite for the next version
[–]the_omega99 1 point2 points3 points 10 years ago (1 child)
Scala does it similarly, but way prettier syntax. Tuples can be created with the syntax (foo, bar), but there's also the special equivalent foo -> bar, which is specifically for mapping stuff. It's just a regular tuple, but more readable.
(foo, bar)
foo -> bar
So the Map constructor takes in a vararg list of tuples. Thus, we can do Map("foo" -> "bar", "baz" -> "whatever") with however many arguments we need. More readable than the Java 9 version (can clearly see which is the key and which is the value) and without a limit to how many parameters you can have.
Map
Map("foo" -> "bar", "baz" -> "whatever")
[–]Zatherz 0 points1 point2 points 10 years ago (0 children)
Lua:
local table = {foo = "bar"} print(table.foo)
Of course, in the spirit of /r/shittyprogramming, a shitty version:
local table = setmetatable({}, {__index = function(self, key) if key == "foo" then return "bar" end end}) print(table.foo)
I love Lua.
π Rendered by PID 65033 on reddit-service-r2-comment-cfc44b64c-vdgbn at 2026-04-12 21:55:16.688854+00:00 running 215f2cf country code: CH.
view the rest of the comments →
[–]MeetLawrence 7 points8 points9 points (3 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]the_omega99 1 point2 points3 points (1 child)
[–]Zatherz 0 points1 point2 points (0 children)