Is there a way to leave pointy block before its end?

  • A+

For example:

$supply.tap: -> $message {     return unless server-is-alive( );   # forbidden!     send-to-server( $message ); } 

I know I can ".tap: sub ($message) { return unless ...; # works! }". But I'd like to know if there is any control flow related to block that simply can interrupt it.


At present, there is no such mechanism. However, it has been suggested that there could be a leave, which would do what you're requesting.

When working with a Supply it's usually better to use the supply/react/whenever syntax. If using that, there is another solution: since whenever is an async loop construct, then one could write:

whenever $supply -> $message {     next unless server-is-alive( );     send-to-server( $message ); } 

The next here meaning that the rest of the block is skipped.


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: