1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Dartやらざあ

Posted at

はじめまして。私は地方で情報系学生(2年生)をしています。
そんな私ですが今年の夏休み、なにかアプリ開発したくFlutterの勉強をすることにしました!

勉強日記がてらやっていこうと思います!

Dartの基本文法

Hello, World!

void main() {
  print("Hello, World!");  //Hello, World!
}

実行方法

$ dart ソースファイル

コマンドライン引数を使う

void main(List<String> args) {
  print(args);
}
$ dart sample.dart アプリ開発 したい
[アプリ開発, したい]

Javaのリストみたいなのを使うんですね!!

型推論

void main() {
  var name = "dart man";
  var age = 19;
  var weeks = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
  //Map型
  var image = {
    'dog': ['犬'],
    'url': "https://qiita.com/"
  };
}

C系にかなり似ていますがMap型というものがあります。

Map型とは

  • キーとペアとなるコレクション
Map<String, int> scores = {
    "Alice" : 100,
    "Bob" : 20
};

print(scores["Alice"]);  //100
print(scores["Bob"]);    //20

条件分岐

基本的にJavaと同じ

再帰関数

void main() {
  print(fibonacci(30)); //832040
}

int fibonacci(int num) {
  if (num == 0 || num == 1) return num;
  return fibonacci(num - 1) + fibonacci(num - 2);
}

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?