Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Ternary conditional operator
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Programming languages without the conditional operator== The following are examples of notable general-purpose programming languages that don't provide a conditional operator: * [[CoffeeScript]] * [[Go (programming language)|Go]] programming language<ref name="go-ternary">{{cite web |url= https://go.dev/doc/faq#Does_Go_have_a_ternary_form |work= The Go Programming Language FAQ |title= Does Go have the ?: operator? |access-date= 2012-08-05}}</ref> (although provided by 3rd-party libraries<ref>{{Cite web |title=lo package - github.com/samber/lo - Go Packages |url=https://pkg.go.dev/github.com/samber/lo#Ternary |access-date=2023-09-30 |website=pkg.go.dev}}</ref>) * [[MATLAB]] * [[Pascal (programming language)|Pascal]] although [[Object Pascal|Object Pascal / Delphi]] do have a function {{code|IfThen}} to do the same (with caveats) * [[Rust (programming language)|Rust]] The {{code|if..else}} construct is an expression and can be used to get the same functionality.<ref>{{cite web |url= http://doc.rust-lang.org/reference.html#if-expressions |work= The Rust Reference |title= If expressions |access-date= 2015-07-21}}</ref> * [[Scala (programming language)|Scala]] * {{ill|XProfan|de|XProfan}} * [[PowerShell]] (in old versions) an elegant workaround is to use <code>(''<value for true>'',''<value for false>'')[!(''<condition>'')]</code><ref>{{Cite web|url=https://stackoverflow.com/questions/31341998/ternary-operator-in-powershell|title=Ternary operator in PowerShell|website=Stack Overflow|access-date=2018-10-09}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)