rfc:check_and_set

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

rfc:check_and_set [2018/07/06 13:25] – created malukenhorfc:check_and_set [2018/07/06 13:30] (current) malukenho
Line 12: Line 12:
 `<nowiki>$x += 3</nowiki>`. `<nowiki>$x += 3</nowiki>`.
  
-With PHP being a web focused language, the `?:` operator is often used to check something's existence like `<nowiki>$this->obj = $obj ?: new \stdClass;</nowiki>` However, because+With PHP being a web focused language, the `?:` ternary operator is often used to check something's existence like `<nowiki>$this->obj = $obj ?: new \stdClass;</nowiki>` However, because
 variable names are often much longer than `<nowiki>$username</nowiki>`, the use of `<nowiki>?:</nowiki>` for self assignment creates repeated code, like: variable names are often much longer than `<nowiki>$username</nowiki>`, the use of `<nowiki>?:</nowiki>` for self assignment creates repeated code, like:
  
Line 19: Line 19:
 </code> </code>
  
-It is also intuitive to use combined assignment operator null coalesce checking for self assignment.+It is also intuitive to use combined assignment operator null ternary checking for self assignment.
  
 # Proposal # Proposal
  
-Despite `<nowiki>?:</nowiki>` operator being a comparison operator, coalesce equal or `<nowiki>?=</nowiki>` operator is an assignment operator. If the left parameter is null, assigns the value of the right paramater to the left one. If the value is not null, nothing is made.+Despite `<nowiki>?:</nowiki>` operator being a comparison operator, ternary equal or `<nowiki>?=</nowiki>` operator is an assignment operator. If the left parameter is null, assigns the value of the right paramater to the left one. If the value is not null, nothing is made.
  
  
rfc/check_and_set.1530883552.txt.gz · Last modified: 2018/07/06 13:25 by malukenho