View Source Orb.Control (Orb v0.1.1)

Summary

Functions

Declare a block, useful for structured control flow.

Break from a block.

Break from a block if a condition is true.

Functions

Link to this macro

block(identifier, result_type \\ nil, list)

View Source (macro)

Declare a block, useful for structured control flow.

defmodule Example do
  use Orb

  defw example do
    Control.block Validate do
      Validate.break(if: i < 0)

      # Do something with i
    end
  end
end

Break from a block.

defmodule Example do
  use Orb

  defw example do
    Control.block Validate do
      # Other code…

      Control.break(Validate)
    end
  end
end

Break from a block if a condition is true.

defmodule Example do
  use Orb

  defw example do
    Control.block Validate do
      Validate.break(if: i < 0)

      # Do something with i
    end
  end
end