我正在尝试使 while 循环将语句精确循环一秒钟,然后停止。我在 DartPad 中尝试过此操作,但它会使浏览器窗口崩溃。
void main(){
var count = 0.0;
bool flag = true;
Future.delayed(Duration(seconds: 1), (){
flag = false;
});
while (flag){
count++;
}
print(count);
}
Run Code Online (Sandbox Code Playgroud)
难道我做错了什么?
当我尝试将一个对象与任何具有13或26或7值的元素存储在一起,然后尝试读取此文件时,它只是给出了垃圾值。其他值(例如1、64、78(随机值))则不会发生这种情况。
我分别使用了ofstream和ifstream来保持代码简单。我正在使用旧的编译器(Borland C ++),但是我的朋友们没有遇到此错误。
#include <iostream.h>
#include <conio.h>
#include <fstream.h>
class xyz
{
public:
int x;
};
void main()
{
xyz a;
a.x = 45; // replace by 45 or 78 it works. Replace by 13, 26 it shows garbage values.
ofstream of;
of.open("file.dat", ios::out||ios::binary);
of.write((char*)&a, sizeof(a));
of.close();
xyz b;
ifstream sf;
sf.open("file.dat", ios::in||ios::binary);
sf.read((char*)&b, sizeof(b));
sf.close();
cout<<b.x;
getch();
}
Run Code Online (Sandbox Code Playgroud)
当前输出将是45,但是如果将其替换为13或26,它将返回垃圾值。
如何确定传递的函数是否是异步函数。例如:
void checkSync(Function func) {
if (func is asynchronous) print('async function');
else print ('not async function');
}
Run Code Online (Sandbox Code Playgroud) !a
JavaScript 中的和之间有区别吗a===null
?我正在从事一个表现不同的项目。
我不是在谈论布尔值,但!true
我不会和true===null
if (!this.props.user)
结果为真,
好像(this.props.user === null)
结果为 false