Skip to content

Instantly share code, notes, and snippets.

@samuelgoto
Last active July 25, 2017 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelgoto/d63c6014b1caa76ee1e73fc43288e019 to your computer and use it in GitHub Desktop.
Save samuelgoto/d63c6014b1caa76ee1e73fc43288e019 to your computer and use it in GitHub Desktop.

Trying to collect some options discussed here and see what they look like with syntax highlighting from various threads (see reference).

// ruby
let map = { a => 1, b => 2, c => 3 };

// kotlin
let map = { a to 1, b to 2, c to 3 };

// swift
let map = [ a: 1, b: 2, c: 3]
let set = {1, 2, 3}

let map = {{ a: 1, b: 2, c:3 }};
let set = [[1, 2, 3]];
map[[a]]; // returns 1.

let set = {<1, 2, 3>};

let map = Map {a: 1, b: 2, c: 3};

let map = {|a: 1, b: 2, c:3|};
let set = {<1, 2, 3>};

let map = {: a: 1, b: 2, c: 3 :};
let set = {. 1, 2, 3 .};

// Are these impossible?
let map = <a: 1, b: 2, c:3>
let set = <1, 2, 3>;
map<a>; // returns 1

let map = { a = 1, b = 2, c = 3}

map{a}; // returns 1.

Notes:

[] = lists
() = tuples
{} = maps
<> = sets

Reference

@samuelgoto
Copy link
Author

@adamk collected a few ideas that I saw thrown around in different threads. i kind of like

let map = { a => 1, b => 2, c => 3 };

for maps.

Any idea if any of the following is syntactically viable?

// Are these impossible?
let map = <a: 1, b: 2, c:3>
let set = <1, 2, 3>;

@samuelgoto
Copy link
Author

@waldemarhorwat would you be able to eye-ball some of these options and identity which are syntactically feasible and which are not?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment