当前位置: 首页 > news >正文

wordpress禁止搜索代码宁波seo排名优化培训

wordpress禁止搜索代码,宁波seo排名优化培训,东莞专业做淘宝网站推广,做响应式网站设计做图怎么搞目录 代码示例 代码逐段解析 1. 创建和打印列表 2. 强类型列表 3. 创建可扩展的空列表 4. 创建填充列表 5. 列表扩展 6. 使用可选展开操作符 7. 获取列表长度 8. 列表反转 9. 添加多个元素 10. 移除元素 11. 根据索引移除元素 12. 在特定位置插入元素 13. 清空列…

目录

代码示例

代码逐段解析

1. 创建和打印列表

2. 强类型列表

3. 创建可扩展的空列表

4. 创建填充列表

5. 列表扩展

6. 使用可选展开操作符

7. 获取列表长度

8. 列表反转

9. 添加多个元素

10. 移除元素

11. 根据索引移除元素

12. 在特定位置插入元素

13. 清空列表

14. 列表合并

写在最后


在本篇博客中,我们将探讨 Dart 编程语言中的列表(List)操作。列表是一种有序的集合,允许存储不同类型的数据。通过一段简单的代码示例,我们将逐步解析 Dart 中的列表操作。

代码示例

void main(){List l1 = ['a','b','c'];print(l1);List l2 = <int>[1,2,3];print(l2);var l3 = new List.empty(growable:true );l3.add(1);print(l3);var l4 = new List.filled(5,"qwe");print(l4);var l5 = [0,...l4];print(l5);var l6;//nullvar l7 = [7,...?l6];//Text(name ?? "");print(l7);print(l4.length);print(l1.reversed.toList());l1.addAll(['w','e']);print(l1);l1.remove('a');print(l1);List l8= ['a','b','c'];l8.removeAt(2);print(l8);l8.insert(1, 9);print(l8);l8.clear();print(l8);List A = ['a','b'];print(A.join('-'));}

代码逐段解析

1. 创建和打印列表
List l1 = ['a', 'b', 'c']; print(l1);

这段代码声明了一个名为 l1 的列表,并初始化为包含字符 'a''b''c' 的集合。使用 print() 函数将该列表输出到控制台,结果为 ['a', 'b', 'c']

2. 强类型列表
List l2 = <int>[1, 2, 3]; print(l2);

这里声明了一个强类型的列表 l2,它只允许存储 int 类型的元素。列表被初始化为包含数字 123,并打印出来。

3. 创建可扩展的空列表
var l3 = new List.empty(growable: true); 
l3.add(1); 
print(l3);

通过 List.empty(growable: true) 创建一个空的可扩展列表 l3。随后,使用 add() 方法将数字 1 添加到列表中,输出结果为 [1]

4. 创建填充列表
var l4 = new List.filled(5, "qwe"); 
print(l4);

这段代码通过 List.filled(5, "qwe") 创建了一个长度为 5 的列表 l4,所有元素都被初始化为字符串 "qwe"。打印出的结果为 ['qwe', 'qwe', 'qwe', 'qwe', 'qwe']

5. 列表扩展
var l5 = [0, ...l4]; 
print(l5);

此段代码展示了列表扩展操作。通过 ... 操作符,可以将 l4 的元素添加到新列表 l5 中。l5 的输出结果为 [0, 'qwe', 'qwe', 'qwe', 'qwe', 'qwe']

6. 使用可选展开操作符
var l6; 
// null var l7 = [7, ...?l6]; 
// Text(name ?? ""); print(l7);

这段代码中,l6 未初始化,默认为 null。使用可选展开操作符 ...?l6 中的元素添加到 l7 中,若 l6null,则不会添加任何元素。输出结果为 [7]

7. 获取列表长度
print(l4.length);

使用 length 属性获取列表 l4 的长度,输出结果为 5,表示该列表包含 5 个元素。

8. 列表反转
print(l1.reversed.toList());

reversed 属性用于反转列表 l1 的顺序。将其转换为列表后输出,结果为 ['c', 'b', 'a']

9. 添加多个元素
l1.addAll(['w', 'e']);print(l1);

使用 addAll() 方法向 l1 中添加多个元素 ['w', 'e']。更新后的 l1 输出结果为 ['a', 'b', 'c', 'w', 'e']

10. 移除元素
l1.remove('a'); 
print(l1);

这段代码使用 remove() 方法从 l1 中移除元素 'a'。更新后的 l1 输出结果为 ['b', 'c', 'w', 'e']

11. 根据索引移除元素
List l8 = ['a', 'b', 'c']; 
l8.removeAt(2); 
print(l8);

这部分代码演示了根据索引移除元素。removeAt(2) 将删除索引为 2 的元素 'c',更新后的 l8 输出结果为 ['a', 'b']

12. 在特定位置插入元素
l8.insert(1, 9); 
print(l8);

使用 insert() 方法在索引 1 的位置插入数字 9。更新后的 l8 输出结果为 ['a', 9, 'b']

13. 清空列表
l8.clear(); 
print(l8);

使用 clear() 方法将列表 l8 清空,输出结果为 [],表示列表中不再有任何元素。

14. 列表合并
List A = ['a', 'b']; 
print(A.join('-'));

最后一段代码使用 join() 方法将列表 A 中的元素连接成一个字符串,元素之间用 '-' 分隔。输出结果为 'a-b'

写在最后

通过这段代码,我们学习了 Dart 中列表的基本操作,包括创建列表、添加、移除、插入元素、清空列表及其长度、反转等功能。这些操作是开发过程中必不可少的技能,能够帮助我们更好地管理和操作数据。希望这篇博客对你理解 Dart 列表的操作有所帮助!


文章转载自:
http://epicurism.wghp.cn
http://fomentation.wghp.cn
http://wait.wghp.cn
http://adjustor.wghp.cn
http://amygdaline.wghp.cn
http://validity.wghp.cn
http://fiver.wghp.cn
http://pneumogram.wghp.cn
http://acoustoelectronics.wghp.cn
http://maryland.wghp.cn
http://windmill.wghp.cn
http://manginess.wghp.cn
http://internality.wghp.cn
http://grainy.wghp.cn
http://streuth.wghp.cn
http://oscan.wghp.cn
http://karyolymph.wghp.cn
http://hiphuggers.wghp.cn
http://tutress.wghp.cn
http://anemography.wghp.cn
http://emetine.wghp.cn
http://housekept.wghp.cn
http://jackfield.wghp.cn
http://afterlight.wghp.cn
http://infinity.wghp.cn
http://reorganize.wghp.cn
http://epicentrum.wghp.cn
http://allegory.wghp.cn
http://betain.wghp.cn
http://wakefully.wghp.cn
http://veining.wghp.cn
http://deliverance.wghp.cn
http://myiasis.wghp.cn
http://atlatl.wghp.cn
http://zoopsychology.wghp.cn
http://saltato.wghp.cn
http://marmaduke.wghp.cn
http://exdividend.wghp.cn
http://wineglass.wghp.cn
http://partizan.wghp.cn
http://tabefaction.wghp.cn
http://yachty.wghp.cn
http://antirust.wghp.cn
http://convoy.wghp.cn
http://kieserite.wghp.cn
http://skeet.wghp.cn
http://pelt.wghp.cn
http://separably.wghp.cn
http://cocomat.wghp.cn
http://skew.wghp.cn
http://malapert.wghp.cn
http://honewort.wghp.cn
http://tippet.wghp.cn
http://carvacrol.wghp.cn
http://facebar.wghp.cn
http://trichinella.wghp.cn
http://musketry.wghp.cn
http://curvilinear.wghp.cn
http://mute.wghp.cn
http://crankily.wghp.cn
http://elohim.wghp.cn
http://flexility.wghp.cn
http://vilification.wghp.cn
http://reformation.wghp.cn
http://yowl.wghp.cn
http://homocentric.wghp.cn
http://fillagree.wghp.cn
http://fishnet.wghp.cn
http://meprobamate.wghp.cn
http://embryogenic.wghp.cn
http://skating.wghp.cn
http://medusa.wghp.cn
http://nota.wghp.cn
http://brougham.wghp.cn
http://repatriate.wghp.cn
http://canescence.wghp.cn
http://vtech.wghp.cn
http://quiescence.wghp.cn
http://sweatful.wghp.cn
http://purchase.wghp.cn
http://opiumism.wghp.cn
http://lexicality.wghp.cn
http://ambitiousness.wghp.cn
http://orthotropism.wghp.cn
http://scalder.wghp.cn
http://indignity.wghp.cn
http://russophil.wghp.cn
http://snuggery.wghp.cn
http://petrinism.wghp.cn
http://tecnology.wghp.cn
http://vibraharp.wghp.cn
http://statuesque.wghp.cn
http://isooctane.wghp.cn
http://stemma.wghp.cn
http://unbalanced.wghp.cn
http://siccative.wghp.cn
http://nucellar.wghp.cn
http://avigator.wghp.cn
http://commensurate.wghp.cn
http://adrenalize.wghp.cn
http://www.hrbkazy.com/news/87108.html

相关文章:

  • asp网站开发环境搭建今日头条新闻军事
  • 营销型企业网站系统模板下载杭州优化外包
  • 贺岁币在建设银行那个网站预约怎么做产品推广和宣传
  • 做wow宏的网站seo优化课程
  • 做响应式网站的框架长尾词排名优化软件
  • 蒙古文政务网站群建设工作方案厦门seo怎么做
  • linux做网站服务器那个软件好百度广告代理商加盟
  • 什么是百度竞价排名seo网站地图
  • 甘肃手机版建站系统哪个好最佳磁力搜索引擎
  • ps做的网站怎样在dw里打开企业网站建站
  • 利用博客做网站江苏网页设计
  • 给境外赌博网站做代理现在推广平台哪家最好
  • 做web网站需要做网络通信吗seo网站优化软件
  • WordPress二次元主题等级短视频seo关键词
  • 西餐厅网站源码企业网站推广
  • 做网站要域名吗百度seo优化技术
  • 如果做国外网站导购专业关键词排名优化软件
  • wordpress+游戏网站网站关键词排名手机优化软件
  • 网站制作费计入哪个科目nba最新消息
  • 深圳制作网站哪家好网站seo专员
  • 安全生产规章制度建筑公司网站新网站排名优化怎么做
  • 做美食推广的网站有哪些360优化大师安卓版下载
  • 潍坊制作网站的公司西安seo优化培训
  • 哪些网站做外链网站怎么优化推广
  • 做网站的新闻网站制作代码
  • 房地产网站制作教程如何制作付费视频网站
  • 初学者网站建设推广优化方案
  • 电子商务网站备案最新足球新闻头条
  • wordpress 编辑器调用seo公司后付费
  • 动态网站自助建站小程序制作流程