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

Chapter 3 main example hyper operator #47

Open
jeteve opened this issue Mar 6, 2011 · 1 comment
Open

Chapter 3 main example hyper operator #47

jeteve opened this issue Mar 6, 2011 · 1 comment
Labels

Comments

@jeteve
Copy link
Contributor

jeteve commented Mar 6, 2011

I'm going through the book using rakudo star - jab 2011, and in chapter 3, there's the following issue:

The code in the book says:

 my $label-area-width = 1 + [max] @scores».key».chars;

The '>>' after key causes the label_area_width to be too big, so I think it should be

 my $label-area-width = 1 + [max] @scores».key.chars;

Is it right?

@moritz
Copy link
Contributor

moritz commented Mar 28, 2011

The example in there produces the output

Ana     XXXXXXXXXXXXXXXXXXXXXX
Dave    XXXXXXXXXXXXXXXX
Charlie XXXXXXXXXXX
Beth    XXXXXXXXXXX

for me, which looks correct (when viewed with a monospace font).

What output did you expect? or why did think that $label-area-width is too big?

Also the code itself looks correct me -- with the >> it calculates the max of the lengths of all keys, without it it would interpreter the list of keys as a string (thus joining it with a space), and calculating its length, then taking the max of one value. NOt very good.

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

No branches or pull requests

2 participants