website icon indicating copy to clipboard operation
website copied to clipboard

Invalid Elixir block syntax in "Gleam for Elixir Users"

Open jpalardy opened this issue 1 year ago • 3 comments

I was reading the Blocks section of the Gleam for Elixir Users and I was surprised by this syntax — when I tried it in iex, it's not valid Elixir

x = do
  print(1)
  2
end

(code link)

Screenshot 2024-02-07 at 10 27 19

Maybe there is a syntax, but I couldn't find it 🤔

(I saw 1.14 in the screenshot, but I tried 1.15 and 1.16 too: same problem)

jpalardy avatar Feb 07 '24 18:02 jpalardy

This seems to be correct?

iex(1)> x = (
...(1)>   IO.puts(1)
...(1)>   2
...(1)> )
1
2
iex(2)> x
2
iex(3)>

inoas avatar Feb 07 '24 21:02 inoas

https://hexdocs.pm/elixir/1.16.1/syntax-reference.html#blocks ... same for ages https://hexdocs.pm/elixir/1.8.0/syntax-reference.html#blocks

inoas avatar Feb 07 '24 21:02 inoas

Yep, that works 👍

Should I open a PR, or you've got it?

jpalardy avatar Feb 08 '24 02:02 jpalardy