Dev study and notes

[dart] #19 #3.5 Typedef (04:50) 본문

studyLog

[dart] #19 #3.5 Typedef (04:50)

devlunch4 2023. 5. 3. 06:00
반응형
typedef ListOfInts = List<int>;

ListOfInts reverseListOfNumbers(List<int> list) {
    var reversed = list.reversed;
    return reversed.toList();
}

typedef UserInfo = Map<String, String>;

String sayHi(UserInfo userInfo) {
    return 'Hi! ${userInfo['name']}';
}

void main() {
    print(reverseListOfNumbers([1, 2, 3]));
    print(sayHi({'name': 'lunch'}));
}

// PRINT
// >>>
// [3, 2, 1]
// Hi! lunch
반응형
Comments