Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow array-like pair dereferencing #134

Open
cjllanwarne opened this issue Sep 18, 2017 · 5 comments
Open

Allow array-like pair dereferencing #134

cjllanwarne opened this issue Sep 18, 2017 · 5 comments

Comments

@cjllanwarne
Copy link
Contributor

As mentioned a couple of times, the pair dereferencing is not intuitive (you have to look it up in the docs to be able to find it). Perhaps we could additionally support array-style dereferencing?

Pair[Int, Int] p = (100, 22)
Int one_hundred = p[0]
Int twenty_two = p[1]
@patmagee
Copy link
Member

patmagee commented Mar 9, 2018

I like this approach better than the .left and .right way tbh. To me, this is more consistent with a two element tuple, whereas left/right are not really used anywhere else in the wild for referencing somehting that even remotely looks like a pair

@cjllanwarne
Copy link
Contributor Author

@patmagee if we do this, a more intuitive json input might be a good idea too- do you have any thoughts on what that might look like? Right now it's:

{
  "pair": {
    "left": 100,
    "right": 22
  }
}

@patmagee
Copy link
Member

patmagee commented Mar 9, 2018

@cjllanwarne The One thing I DO like about pair is that it differentiates itself from an array type, however it could be interpreted as a fancy map like type.

One way would be the simplest, which would be a 2 element Array

{
   "pair": [ 100, 22 ]
}

this is similar to the Pair-literal of (100,22)

@geoffjentry
Copy link
Member

left/right always struck me as being too tied to Scala's Either (where I also dislike the left/right terminology).

@jdidion
Copy link
Collaborator

jdidion commented Feb 7, 2024

Related to #279. But I wouldn't mind either pair[0], pair[1] or pair.0, pair.1. Would still continue to support left and right.

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

No branches or pull requests

4 participants