Advertisement
Hiteshw11

Return Map Values In A Set

Nov 23rd, 2024
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.36 KB | Source Code | 0 0
  1. /* Write a Dart function that takes a map and returns a set of the map's values. */
  2.  
  3. void main() {
  4.   Map<String,int> mapper ={'apple':1,'banana':2,'orange':3};
  5.   print(maptokeys(mapper));
  6. }
  7.  
  8. Set <int>  maptokeys(mapper)
  9. {
  10.     Set<int> abc ={};
  11.    for(MapEntry<String,int> e in mapper.entries)
  12.     {
  13.        abc.add(e.value);
  14.  
  15.      }
  16.     return abc;
  17. }
  18.  
  19.  
  20.  
Tags: dart
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement