Skip to content

Instantly share code, notes, and snippets.

@mikaelo
Last active March 15, 2021 18:01
Show Gist options
  • Save mikaelo/1197c4339d41a5274fd02efcaa877f95 to your computer and use it in GitHub Desktop.
Save mikaelo/1197c4339d41a5274fd02efcaa877f95 to your computer and use it in GitHub Desktop.
Flutter Surf 2.4 Задание по Переменным и Типам данных
// 1
int a = 1;
void main() {
// 2
double b;
// 3
var text = "text";
//text = a; - ошибка при компиляции
// 4
dynamic dyn = text; // в переменной dyn будет значения переменной text
// 5 - значение const должно быть известно на момент компиляции
final fin = 200;
const con = 3.14;
// fin = 100; // ошибка при компиляции
// con = 0.01; // ошибка при компиляции
// 6
int speed = 60;
//var isEven = speed % 2 == 0;
print(speed.isEven);
// 7
print("I \u2665 dart");
// 8
var list = [1,2,3,4,5,6,7,8]; // a
print(list.length); // b
list.sort((a,b) => -a.compareTo(b)); // c
print(list); // c
var newlist = list.skip(1).take(3); // d
print(newlist); // d
print(list.indexOf(5)); // e
list.removeWhere((x) => x >= 5 && x <= 8); // f
print(list); // f
list.addAll([10, 20, 30]); // g
print(list); // g
// 9
// a
var numberBook = <String, String>{
"Иван": "2264865",
"Татьяна": "89523366684",
"Олег": "84952256575"
};
// b
print(numberBook);
// c
numberBook.putIfAbsent("Екатерина", () => "2359942");
// d
var sortedKeys = numberBook.keys.toList()..sort((a, b) => -a.compareTo(b));
var sortedNumberBook = {for (var key in sortedKeys) key : numberBook[key]};
print(sortedNumberBook);
// 10
// a
var mySet = <String>{'Москва', 'Вашингтон' ,'Париж'};
// b
mySet.add('Вашингтон');
print(mySet.length); // Set (множество) содержит уникальные значения, значение Вашингтон уже было в множестве при создании
// c
var input = '''"She sells sea shells on the sea shore;
The shells that she sells are sea shells I'm sure.
So if she sells sea shells on the sea shore,
I'm sure that the shells are sea shore shells"''';
print(input);
print(input
.replaceAll(new RegExp(r'[^\w]+'),' ')
.trim()
.split(' ')
.length); // если считать I'm - два слова
}
@dkrutskikh
Copy link

можно воспользоваться speed.isEven что-бы узнать четное число или нет

В 9ом задание, пункт 9.4 требуется вывести в обратном порядке

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