Crystal: bracket style blocks around if statments

Created on 11 Jul 2020  路  4Comments  路  Source: crystal-lang/crystal

Right now if statements only has an if and end like.

if true
  x = foo
end

It would be nice to also have the option to have bracket block style arguments if statements like.

if true {
  x = foo
}

This would enable a more c style structure but would be more flexible.

Most helpful comment

I don't see any benefit from that. It would just be another way to do the same thing and we try to avoid that in Crystal. It's a purely stylistical issue. So I don't suppose this is worth pushing forward.

All 4 comments

I think it will conflict with the block argument to the calling method in the conditional.

if [1, 2, 3].any? { |x| x == 1 }
  x = foo
end

I don't see any benefit from that. It would just be another way to do the same thing and we try to avoid that in Crystal. It's a purely stylistical issue. So I don't suppose this is worth pushing forward.

please don't

I was also going to comment about the syntax conflict. I don't think this will ever happen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

grosser picture grosser  路  3Comments

oprypin picture oprypin  路  3Comments

Papierkorb picture Papierkorb  路  3Comments

pbrusco picture pbrusco  路  3Comments

relonger picture relonger  路  3Comments