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

Update types.tex #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update types.tex #2

wants to merge 1 commit into from

Conversation

Matt--
Copy link
Contributor

@Matt-- Matt-- commented Apr 19, 2014

Added to Tuples example,lines 306-309

Now shows a tuple being created, used as a parameter, deconstructed and returned as a new tuple. Recommend keeping the comment as the phrase does not come up anywhere in the doc. I had to google it, my google foo was good...

This editing change was pretty easy to do, I'll send more your way as I find them.
** Just spotted a change on lines 732 & 734. I have no idea how I did those two, they are not part of my suggested change...

Added to Tuples example,lines 306-309

Now shows a tuple being created, used as a parameter, deconstructed and returned as a new tuple. Recommend keeping the comment as the phrase does not come up anywhere in the doc. I had to google it, my google foo was good...

This editing change was pretty easy to do, I'll send more your way as I find them.
@DavePearce
Copy link
Member

Hey Matt,

So, whats the thinking here ... to show off more tuple syntax? The modified function is ratger ugly compared to the original...

D

@Matt--
Copy link
Contributor Author

Matt-- commented Apr 20, 2014

Hi Dave,
The original is definitely shorter.

function swap(int x, int y) => (int,int):
    return y,x

But it doesn't really demonstrate tuple use. It takes two ints and returns a tuple.

This function, I suggest better matches the context text;
"Example. The following example illustrates several uses of tuples:"

(int, int) x = (4, 5)

function swap((int,int) x) => (int,int):
    int a, int b = x      // tuple destructuring assignment
    return b, a

This code demonstrates tuple creation, tuple use and tuple destructuring, in the process swapping the values of a tuple input => tuple output.

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

Successfully merging this pull request may close these issues.

2 participants