goby-lang / goby

Goby - Yet another programming language written in Go
MIT License
3.49k stars 171 forks source link

Support Ternary Operator #677

Open st0012 opened 6 years ago

st0012 commented 6 years ago

For example: foo ? bar : baz

hachi8833 commented 6 years ago

I thought you wouldn't adopt ternary operators in Goby 😲

st0012 commented 6 years ago

Yep I didn’t want to support this, but this is kind of a basic component to programming language I think

eliothedeman commented 6 years ago

Is this something people have complained about not having?

st0012 commented 6 years ago

Not yet, just I think it would be. But it might also because we don't really have much users for now.

Alexius-Huang commented 6 years ago

Just a thought, do you want to do something like in Python style (although Goby is referenced to Ruby style syntax):

hello = 'world' if created? else 'nothing'

But this style is kind of like inline conditional which is addressed in #580

st0012 commented 6 years ago

@Maxwell-Alexius I prefer using Ruby style because python style might confuse users

spavikevik commented 6 years ago

Would you guys let me try to attack this in my free time? I love Ruby and Go, and have tried working with compilers/interpreters before, so I feel like it wouldn't be such an idea to attempt something like this.

st0012 commented 6 years ago

@spavikevik sure, feel free to work on it 😄