Conditionals with Omitted Operands (x ? : y)
Conditionals with Omitted Operands
The middle operand in a conditional expression may be omitted. Thenif the first operand is nonzero, its value is the value of the conditionalexpression.
Therefore, the expression
x ? : y
has the value of x
if that is nonzero; otherwise, the value of
y
.
This example is perfectly equivalent to
x ? x : y
In this simple case, the ability to omit the middle operand is not especially useful. When it becomes useful is when the first operand does,or may (if it is a macro argument), contain a side effect. Then repeating the operand in the middle would perform
the side effect twice. Omitting the middle operand uses the value already computed without the undesirable effects of recomputing it.
x? : y is equal to x?
x:y
Conditionals with Omitted Operands (x ? : y)的更多相关文章
- C#解析字符串公式
/// <summary> /// 中缀表达式到逆波兰表达式的转换及求值 /// </summary> public class RpnExpression { #region ...
- ThinkPHP 汉字转成多种形式拼音
模型: <?php namespace Admin\Model; use Think\Model; /** * 汉字转拼音 * @author huangguojin */ class ZHMo ...
- Conditionals
1. Modulus operator (%) The modulus operator works on integers and yields the remainder when the fir ...
- 【iOS】swift-Binary operator '|' cannot be applied to two UIViewAutoresizing operands
let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 568)) addSubview(view) view.autoresi ...
- Learn X in Y minutes Where X=c++
http://learnxinyminutes.com/docs/c++/ C++ is a systems programming language that, according to its i ...
- 萌新笔记——vim命令“=”、“d”、“y”的用法(结合光标移动命令,一些场合会非常方便)
vim有许多命令,网上搜有一堆贴子.文章列举出各种功能的命令. 对于"="."d"."y",我在无意中发现了它们所具有的相同的一些用法,先举 ...
- Android立体旋转动画实现与封装(支持以X、Y、Z三个轴为轴心旋转)
本文主要介绍Android立体旋转动画,或者3D旋转,下图是我自己实现的一个界面 立体旋转分为以下三种: 1. 以X轴为轴心旋转 2. 以Y轴为轴心旋转 3. 以Z轴为轴心旋转--这种等价于andro ...
- $x^2+y^2=c^2$
$x^2+y^2=c^2$ 每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis. 每一 ...
- android3D动画,绕y轴旋转
原文地址:http://blog.csdn.net/x_i_a_o_h_a_i/article/details/40449847 其实网上的3D旋转的例子很多,在这里我只是想把其代码做一个解释. 先上 ...
随机推荐
- hdu 5612 Baby Ming and Matrix games
Baby Ming and Matrix games 题意: 给一个矩形,两个0~9的数字之间隔一个数学运算符(‘+’,’-‘,’*’,’/’),其中’/’表示分数除,再给一个目标的值,问是否存在从一 ...
- Things About 'extern'
Note: All Learned From Here C和Objective-C的function前面都有个隐含的extern,对于function来说,有没有extern都无所谓,但变量不一样. ...
- STM32之外部中断控制
一.STM32外部中断 1.STM32外部中断结构图 如上图所示:主要包括四个环节,GPIO.AFIO.EXTI.NVIC.以STM32F103VE(100脚)为例说明硬件模块的数量: GPIO: ...
- jedis源码阅读
package redis.clients.jedis; import java.util.ArrayList; import java.util.HashSet; import java.util. ...
- android SurfaceView绘制 重新学习--控制动画移动
直接上demo,图是自己切的,将就用吧.点击左右两边分别向左右移动. public class MySurfaceView extends SurfaceView implements Callbac ...
- javascript之事件
客户端javascript程序采用了异步事件驱动编程模型. 相关事件的几个概念: 事件类型(event type):用来说明发生什么类型事件的字符串: 事件目标(event target):发生事件的 ...
- android app修改包名
change package nameA.使用到得工具 notepad++,everything搜索工具(C:\Users\Administrator\Desktop\MusicScanResu ...
- [JavaScript] js 迅雷评分效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...
- Word删除复制后产生空行
如上图,用网上说的^p^p替换为^p无效,我全选,然后在样式里选择正文才搞定.实践出真知!!!!!!!!!网络上附和的多
- Gabor变换
Gabor变换 Gabor变换属于加窗傅立叶变换,Gabor函数可以在频域不同尺度.不同方向上提取相关的特征.另外Gabor函数与人眼的生物作用相仿,所以经常用作纹理识别上,并取得了较好的效果.Gab ...