Favourite line of Neko, so far

I think I just wrote my favourite line of Neko so far, breaking out of a while loop on a read exception. This was for the Fixed Length Records task on Rosetta Code.

http://rosettacode.org/wiki/Fixed_length_records#Neko

while true {
  try {
    len = file_read(input, record, pos, LRECL)
    if len != LRECL $throw("Invalid read")

    len = file_write(output, reverse(record), pos, LRECL)
    if len != LRECL $throw("Invalid write")
  } catch a break;
}

Never want to hear a programmer say “I can’t catch a break”; sure you can, use Neko. :slight_smile:

Edit: Another nice read in Neko, try v = f() catch with $print("Exception: ", with, "\n")

Have good

1 Like