Hacker News new | comments | show | ask | jobs | submit login

I have to agree with some of the others here and say that not all of the above is very intuitive.

In particular a[3, 5]. I would be expecting it to return elements 3 & 5 (shortcut to a[3] & a[5]) instead of doing a length slice.

For eg, in perl:

  my @a = qw/zero one two three four five six/;

  $a[3];        # "three"   
  @a[3, 5];     # ("three", "five")
  @a[3, 0, 5];  # ("three", "zero", "five")
  @a[1..5];     # ("one", "two", "three", "four", "five")
  
Also the ... operator is slightly at odds when compared against .. operator. I think perl6 has a more intuitive version:

  @a[1..^5];  #  ["one", "two", "three", "four"]
So instead of 1 to 5 (1..5) you think 1 upto 5 (1..^5).



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: