Skip to content

proposal syntax else ... then for else keyword in conditional branches #207

@lyrachord

Description

@lyrachord

examples in tutorial

if a == b then
  env.out.print("they are the same")
else
  if a > b then
    env.out.print("a is bigger")
  else
    env.out.print("b bigger")
  end
end

limited by set pattern in old school

if a == b then
  env.out.print("they are the same")
elseif a > b then
  env.out.print("a is bigger")
else
  env.out.print("b bigger")
end

just use "else ... then" instead of "elseif ... then"

if a == b then
  env.out.print("they are the same")
else a > b then
  env.out.print("a is bigger")
else
  env.out.print("b bigger")
end

And it is ok in expressions

x = 1 + if lots then 100 else afew then 10 else 2 end

And there is almost no additional cost for parsing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions