本文介绍了什么是??在达特的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

在Flutter插件的共享首选项示例中,我看到了该运算符.而且我不明白.

I saw this operator in Example of Shared Preferences for Flutter plugin. And I didn't get it.

int counter = (prefs.getInt('counter') ?? 0) + 1;

推荐答案

它称为空感知运算符

意思是,当且仅当 prefs.getInt('counter')返回 null 时,为其分配 0 ,然后加1.

Meaning, if and only if prefs.getInt('counter') returns null assign 0 to it and then increment by one.

在这里,您可以找到有关空感知运算符的精彩博客文章: http://blog.sethladd.com/2015/07/null-aware-operators-in-dart.html

Here, you can find a great blog post about null-aware operator: http://blog.sethladd.com/2015/07/null-aware-operators-in-dart.html

这篇关于什么是??在达特的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:51