"Breaking loop" in Elixir?

It’s not quite clear what you actually want to accomplish. Often times you can rely on functions in the Enum module to get the behaviour you’re describing. For example, you can use Enum.any?/2 to test if a certain value in the enumerable satisfies some condition:

[1,2,3,5] 
|> Enum.any?(fn x -> x == 3 end)

But this still will only return a boolean. The fragment you posted will always return :ok. But combining Enum.any/2 with some conditional logic might lead you to the correct solution.

If you really want to implement some loop and return early (but I really don’t thing you need that, because 99% of the time there are better abstractions that do the heavy lifting for you), you can look at Enum.reduce_while/3 and friends, that allow you to halt the reduction.