Skip to content

Instantly share code, notes, and snippets.

@Headmast
Created September 30, 2020 19:15
Show Gist options
  • Save Headmast/f6b4e154d466ca67ccc5c0e860ceb50f to your computer and use it in GitHub Desktop.
Save Headmast/f6b4e154d466ca67ccc5c0e860ceb50f to your computer and use it in GitHub Desktop.
void main() {
  //a
  var list = <int>[1,2,3,4,5,6,7,8];
  print('list: ${list}');
  //b
  print('list: ${list.length}');
  //c
  list.sort((a,b)=> b.compareTo(a));
  print('list: ${list}');
  //d
  var newList = list.sublist(0, 3);
  print('newList: ${newList}');
  //e
  print('Index of 5: ${list.indexOf(5)}');
  //f
  for (var i = 5; i <= 8; i++) {
    list.removeWhere((item) => item == i);
  }
  print('list: ${list}');
  //g - i think it isn't correct task
  for (var i = 1; i <= 3; i++) {
    list.removeWhere((item) => item == i);
  }
  
  list.addAll([10,20,30]);
  print('list: ${list}');
}
@artem-zaitsev
Copy link

Учтем замечание. Не очень хорошо сформулированный пункт.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment