Demo entry 6786721

代码

   

Submitted by anonymous on Apr 03, 2019 at 14:30
Language: Dart. Code size: 731 Bytes.

        // Map的声明
        var hawaiianBeaches = {
            'oahu' : ['waikiki', 'kailua', 'waimanalo'],
            'big island' : ['wailea bay', 'pololu beach'],
            'kauai' : ['hanalei', 'poipu']
        };
        var searchTerms = new Map();

        // 指定键值对的参数类型
        var nobleGases = new Map<int, String>();

        // Map的赋值,中括号中是Key,这里可不是数组
        nobleGase[54] = 'dart';

        //Map中的键值对是唯一的
        //同Set不同,第二次输入的Key如果存在,Value会覆盖之前的数据
        nobleGases[54] = 'xenon';
        assert(nobleGases[54] == 'xenon');

        // 检索Map是否含有某Key
        assert(nobleGases.containsKey(54));

        //删除某个键值对
        nobleGases.remove(54);
        assert(!nobleGases.containsKey(54));

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).