惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Vulnerabilities – Threatpost
F
Fortinet All Blogs
Vercel News
Vercel News
C
Check Point Blog
P
Privacy International News Feed
Know Your Adversary
Know Your Adversary
Google DeepMind News
Google DeepMind News
T
Troy Hunt's Blog
TaoSecurity Blog
TaoSecurity Blog
I
Intezer
T
The Exploit Database - CXSecurity.com
Security Archives - TechRepublic
Security Archives - TechRepublic
H
Hacker News: Front Page
P
Proofpoint News Feed
GbyAI
GbyAI
Engineering at Meta
Engineering at Meta
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
IT之家
IT之家
D
DataBreaches.Net
Hacker News: Ask HN
Hacker News: Ask HN
SecWiki News
SecWiki News
Y
Y Combinator Blog
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
Lohrmann on Cybersecurity
T
Tenable Blog
大猫的无限游戏
大猫的无限游戏
L
LINUX DO - 最新话题
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
Recorded Future
Recorded Future
有赞技术团队
有赞技术团队
Martin Fowler
Martin Fowler
K
Kaspersky official blog
PCI Perspectives
PCI Perspectives
A
Arctic Wolf
Latest news
Latest news
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
N
Netflix TechBlog - Medium
雷峰网
雷峰网
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Google Online Security Blog
Google Online Security Blog
P
Palo Alto Networks Blog
The Hacker News
The Hacker News
WordPress大学
WordPress大学
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
月光博客
月光博客
Schneier on Security
Schneier on Security
M
MIT News - Artificial intelligence

Dart

Dart 中的这个语法特性是什么时候推出的? deno 和 dart 好像啊 [转] Dart 服务器端开发 、 Dart 客户端开发 、Dart 浏览器端开发 和 Dart 云开发 用 Dart 重写了一个原本用 JavaScript 做的小应用 最近学习 Dart 语言,分享一下心得 (入门级) js 转 dart 编译器哪家强? Fuchsia OS 预计还有 75 天后发布 凑热闹, dart 适合做后台吗 [Flutter/Dart] 关于 dart 异步任务执行顺序的问题 Flutter 资料分享 有没有 Dart 的大佬想要写书的,合作吗? - V2EX Dart/Flutter 资料精选 [转] 为什么 Flutter 会选择 Dart ? Dart 在 fuchsia os 上的应用
使用了下 Dart 语言,发现一些特性的设计得非常缜密,例如 List Comprehension
yech1990 · 2020-03-09 · via Dart

就拿大量使用 List Comprehension 的 Python 做比较,

  • Dart 的一个 List Comprehension 里面可以包含多个“逻辑”
  • “逻辑”的结果可以为空

这些特性 Python 需要分为多个 List Comprehension 且外层嵌套逻辑来实现,比如产生这样的一个 List:

( Dart 的实现)

void main() {
  print([
    if (2 > 1) 222 else 333,
    if (2 > 3) 444,
    for (int i in Iterable.generate(10)) if (i % 3 == 1) i,
    for (int i in Iterable.generate(10, (x) => x + 100)) if (i % 2 == 0) i
  ]);
}

output: [222, 1, 4, 7, 100, 102, 104, 106, 108]

https://dartpad.dev/540d15e9a25afb2159ee1b380e98d906

( Python 的实现)

print(
    [if (2 > 1) 222 else 333] + 
    ([444] if (2 > 3) else []) +
    [i for i in range(10) if i % 3 == 1] +
    [i + 100 for i in range(10) if (i + 100) % 2 == 0]
)