Associative array/Iteration: Difference between revisions

Content added Content deleted
No edit summary
Line 767: Line 767:
=={{header|Dart}}==
=={{header|Dart}}==
<lang javascript>
<lang javascript>

main(){
main(){
var fruits = {
var fruits = {
Line 775: Line 776:
'plums': 'purple'
'plums': 'purple'
};
};

print('Key Value pairs:');
fruits.forEach( (fruits, color) => print( '$fruits are $color' ) );
fruits.forEach( (fruits, color) => print( '$fruits are $color' ) );
print('\nKeys only:');
fruits.keys.forEach( ( key ) => print( key ) );
print('\nValues only:');
fruits.values.forEach( ( value ) => print( value ) );
}
}

</lang>
</lang>