Comment

Comment by bhaney

> Can you magically return/break out of iterator functions like you can in Ruby?

Sure can.

    $ cat break.cr
    (1..).each do |x|
      break if x > 2
      puts x
    end
    
    $ crystal break.cr
    1
    2
    
    $
The answer to Crystal questions that end in "like you can in Ruby" is usually "yes." The language really is just Ruby with static typing, warts and all. Most random snippets of Ruby will run just fine when compiled as Crystal.
parent bhaney 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton