我在上次更新后刚刚在vscode中进行调试时遇到问题.有一些事情发生(https://github.com/Microsoft/vscode/issues/45657)
我想查看以前的版本,看看我的案例是在这里还是在vscode中有问题,但我找不到如何降级的说明(我想这是可能的)
是否有一个函数来获取文件路径的目录部分?
所以
String a="/root/sdcard/Pictures/img0001.jpg";
Run Code Online (Sandbox Code Playgroud)
你得到
"/root/sdcard/Pictures"
Run Code Online (Sandbox Code Playgroud) 我是一个以PHP开头的C++程序员.我发现由于未定义的变量,我失去了大部分调试时间(和我的自尊!).据我所知,处理它们的唯一方法是在执行时观察输出.
其他策略是否注意到这些错误?(类似于C++,单个编译为您提供了所需的所有线索)
感谢您的任何见解
When reorganizing a project with many classes, a frequent need is to move some class to another existent file.
I have searched the vscode features and extesions and I haven't been able to find some refactoring that does that.
Anyone knows of such a possiblitly?
我只是想简化一个Select语句:
Select (a+b+c)/3 AS V, MIN((a+b+c)/3) as Min, MAX((a+b+c)/3) as Max from ....
Run Code Online (Sandbox Code Playgroud)
是否有一种干净的方法可以避免在聚合函数中重复该公式(a + b + c)/ 3?
如下所示的字符串枚举看起来很多余,如果您键入某些错误以创建重复项,则代码会很繁琐并且容易出错(请参见以下示例中的最后一个)
enum Cmd{
StartServer = "StartServer",
StopServer = "StopServer",
ResumServer1 = "ResumeServer1",
ResumServer2 = "ResumeServer1" // this would cause problems
}
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种只声明枚举元素并自动将值作为符号名称和可选的前缀的方法
我到达的最远的地方是这样的:
export function stringifyEnum(enu:any, prefix:string=undefined){
Object.keys(enu).forEach( k =>{
if (isNumber(k))
enu[k] = prefix+enu[k]
else
enu[k] = prefix+k
})
}
Run Code Online (Sandbox Code Playgroud)
似乎可行:
enum Cmd{
StartServer,
StopServer,
ResumeServer1,
ResumeServer2
}
stringifyEnum(Cmd,"Cmd")
console.log(Cmd.StartServer) // --> CmdStartServer
Run Code Online (Sandbox Code Playgroud)
到目前为止,使用这种方法,唯一的问题是打字稿认为枚举是数字的并且在某些情况下会抱怨。
有没有更好的方法(这里的主要目标是简洁的枚举),或者您认为这种想法有隐患吗?
在vscode中,我有一个具有多个配置的launch.json.
有没有办法为特定配置分配键盘快捷键?,我无法找到任何信息,谢谢!
最近,我将 C++ 源代码的编码从 ASCII 移至 UTF-8,但我不确定这是一个好主意,因为我在文字方面遇到了一些问题,现在慢慢思考,我没有看到任何优势。
在 C++ 源代码中,哪种编码被视为标准或“最佳实践”?(我的IDE是VStudio和QtCreator,但我想这个问题是通用的)
我有
class Rect{
// stuff
};
Run Code Online (Sandbox Code Playgroud)
和
class SpecialRect:public Rect{
private:
operator const Rect(){return *this;} // No implicits casts to Rect
public:
// stuff
};
Run Code Online (Sandbox Code Playgroud)
SpecialRect继承了Rect的所有属性和方法,但我要避免SpecialRect到基类Rect的非显式转换。
在代码中
SpecialRect oneSpecial;
Rect aRect=oneSpecial; // I want this to not compile. (to remind-me to declare aRect as SpecialTect)
Run Code Online (Sandbox Code Playgroud)
编译没有错误。(我知道将基类Rect声明为私有可以做到这一点,但我不想重新实现其所有方法。)
有没有办法做到这一点?
function isFish(pet: Fish | Bird): pet is Fish {
return (<Fish>pet).swim !== undefined;
}
Run Code Online (Sandbox Code Playgroud)
告诉打字稿宠物类型是 Fish
有没有办法相反,输入参数不是鱼?
function isNotFish(pet: Fish | Bird): pet is not Fish { // ????
return pet.swim === undefined;
}
Run Code Online (Sandbox Code Playgroud)