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

  • iOS Programming Cookbook
  • Hossam Ghareeb
  • 143字
  • 2021-07-09 18:29:43

How it works...

In Double type, we have added two computed properties. The computed properties are properties that will be calculated every time when it's called. We've added a property called absoluteValue, which returns the absolute value; same for intValue, which returns the integer value of double. Then, for any double value in the whole project, these two properties are accessible and can be used.

In the Int type, we have defined three new instance methods. The isEven() method should return true if this number is even, false otherwise, and the same logic applies for isOdd(). The third method that has some more logic is digits(), which returns array of digits in the number. The algorithm is simple; we get the last digit by getting the remainder of piding the number by 10, and then skip the last digit by piding by 10.

主站蜘蛛池模板: 肥乡县| 兰溪市| 德格县| 钟祥市| 潍坊市| 潢川县| 泰州市| 邢台县| 深州市| 偃师市| 乌拉特前旗| 磐安县| 东平县| 日土县| 昔阳县| 清远市| 和静县| 永川市| 永胜县| 鸡泽县| 井冈山市| 章丘市| 津市市| 格尔木市| 柞水县| 漳平市| 阿城市| 兴业县| 谷城县| 巴林右旗| 加查县| 鄂伦春自治旗| 电白县| 林口县| 凤庆县| 荔波县| 平湖市| 澄迈县| 沁水县| 泾川县| 临桂县|