在Dart中是什么意思? [英] What does ~ mean in Dart?

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

问题描述

在Dart的一些代码示例中看到了波浪号。我已经看到它在C ++中用作析构函数,可以在其中调用它来删除对象的实例,它在Dart中具有相同的功能吗? Java中是否有等效的符号?

Seen tilde in a few code examples in Dart. I've seen it used in C++ as a destructor where it can be called to delete the instance of a object Has it the same function in Dart? Is there an equivalent symbol in Java?

推荐答案

运算符为Dart对象上的可重载运算符,因此可以表示您想要的任何内容。在平台库中,唯一的用途是 int.operator〜进行按位求反(类似于C,Java和JavaScript中类似的整数运算符)。

The ~ operator is an overloadable operator on Dart objects, so it can mean anything you want it to. In the platform libraries, the only use is int.operator~ which does bitwise negation (like the similar integer operator in C, Java and JavaScript).

正如GüntherZöchbauer所提到的,也出现在可重载的〜/ 运算符中平台库用于 num.operator〜/ 的整数除法。默认情况下,〜/ 运算符之间没有任何关系。

As Günther Zöchbauer mentions, the ~ also occurs in the overloadable ~/ operator which the platform libraries uses for integer division as num.operator~/. There is no relation between the ~ or ~/ operators by default.

因此,这并不意味着破坏。 Dart不允许进行明确的销毁,也不允许任何销毁-语言规范中没有说明对象死亡的时间。 (实现垃圾收集用户代码无法再看到的对象,以保留内存。)

So, it does not mean "destruction". Dart does not allow explicit destruction, or any destruction at all - the language specification doesn't say when an object dies. (Implementations garbage collect objects that the user code cannot see any more, to preserve memory).

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆