Vocabulary/returndot

From J Wiki
Jump to navigation Jump to search

>> <<   Back to: Vocabulary Thru to: Dictionary

return. Exit with result Control

Valid only inside an explicit definition.


Terminates the verb without executing any further code

  return.         NB. returns the last noun calculated so far.

  y + 1 return.   NB. place the value to be returned BEFORE this control word, not AFTER.

Common Uses

1. Optionally exit a verb definition before the last sentence and return a noun value

return_trial=: 3 : 0
if. y do.
  'y is true' return.
else.
  'y is false'
end.
'...exits'
)

   return_trial 1
y is true

   return_trial 0
...exits