1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Dartのクロージャはこんな感じらしい。

Function makeAdder(num addBy) {

  return (num i) => addBy + i;
}

void main() {
  //addByの引数2を指定したものを変数として格納すると、入れた引数の値を記憶している。
  var add2 = makeAdder(2);
  //addByの引数4を指定したものを変数として格納すると、入れた引数の値を記憶している。
  var add4 = makeAdder(4);

  print(add2(3) == 5);// true
  print(add4(4) == 7);// false
  print(add2(7) == 9);// true
}
1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?