try

From The K Language Wiki
Try
.[f;y;g]

This article is limited to ngn/k. There is scope for addition of the functionality of other major K implementations, if there are any differences.

Try is a primitive which allows executing functions which would otherwise error.

  • f is the function to be tried.
  • y is the list of arguments to be given to the function(like in dot).
  • g is the function to be applied the the error message(given as a string), in case f.y errors.
 .[+;1 2;"E:",]
3
 .[+;1,`2;"E:",]
"E:lmt"