Dart absメソッドを使って絶対値を取得する

環境
OS windows10 Home 64bit
Dart 2.18.4

書式
絶対値を取得するには、「 abs 」を使用します。
数値.abs()

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
void main() {
print((123).abs());
print((-456).abs());
print((12.31).abs());
print((-22.01).abs());
}
void main() { print((123).abs()); print((-456).abs()); print((12.31).abs()); print((-22.01).abs()); }
void main() {
  
   print((123).abs());
  print((-456).abs());
  print((12.31).abs());
  print((-22.01).abs());
}

実行結果
123
456
12.31
22.01

Dart

Posted by arkgame