官术网_书友最值得收藏!

Basic operators

Swift provides the following basic operations:

  • The = operator for assignments, similar to many different programming languages.
  • The + operator for addition, - for subtraction, * for multiplication, / for pision, and % for remainders. These operators are functions that can be passed to other functions.
  • The -i operator for unary minus and +i for unary plus operations.
  • The +=, -=, and *= operators for compound assignments.
  • The a == b operator for equality, a != b for inequality, and a>b, a<b, and a<=b for greatness comparison.
  • The ternary conditional operator, question ? answer1: answer2.
  • nil coalescing a ?? b unwraps optional a if it has a value and returns a default value b if a is nil.
  • Range operators:
    • Closed range (a...b) includes the values a and b
    • Half-open range (a..<b) includes a but does not include b
  • Logical operators:
    • The !a operator is NOT a
    • The a && b operator is logical AND
    • The a || b operator is logical OR
主站蜘蛛池模板: 广饶县| 拉孜县| 乐陵市| 乌兰察布市| 鱼台县| 长治县| 威信县| 当涂县| 高州市| 揭西县| 长宁县| 桐乡市| 大港区| 搜索| 朝阳区| 策勒县| 自贡市| 芜湖市| 佛学| 平昌县| 房山区| 宝鸡市| 通化市| 桑植县| 尉犁县| 常宁市| 翁源县| 军事| 嫩江县| 且末县| 宜都市| 莆田市| 南城县| 海伦市| 旬阳县| 松江区| 马鞍山市| 油尖旺区| 高陵县| 仲巴县| 来安县|