单步执行a时sqlite3_stmt,我想检查返回值NULL而不是存储它并检查存储的值.
这就是我现在正在做的事情:
char *email = (char *)sqlite3_column_text(statement, 10);
if (email == NULL) email = "";
Run Code Online (Sandbox Code Playgroud)
这里是想什么,我想在做,减去双呼叫column:
char *email = ((char *)sqlite3_column_text(statement, 10)) ? (char *)sqlite3_column_text(statement, 10) : "";
Run Code Online (Sandbox Code Playgroud)
有没有办法更简洁地表达第二个表达式?我必须重复做很多这些,所以我正在寻求简洁.
我知道这是控制流的问题,而不是SQLite API本身的问题,但是你有它.我想不出这样做的好方法.
请原谅noob问题,但为什么我不能(几乎)从coffeeREPL中调用(几乎)任何标准函数(或者从TextMate中编写并运行的文件)?
变量赋值工作,函数没有.
例子:
coffee> string = "string"
'string'
coffee> list = [1,2,3]
[ 1, 2, 3 ]
coffee> num = 42
42
coffee> opposite = true
true
coffee> num = -42 if opposite
-42
Run Code Online (Sandbox Code Playgroud)
但
coffee> alert "Hello, World"
ReferenceError: alert is not defined
at repl:1:5
at REPLServer.replDefaults.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:33:28)
at repl.js:239:12
at Interface.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/repl.js:62:9)
at Interface.EventEmitter.emit (events.js:117:20)
at Interface._onLine (readline.js:202:10)
at Interface._line (readline.js:531:8)
at Interface._ttyWrite (readline.js:760:14)
at ReadStream.onkeypress (readline.js:99:10)
at ReadStream.EventEmitter.emit (events.js:117:20)
Run Code Online (Sandbox Code Playgroud)
和
coffee> print "Hello"
ReferenceError: print …Run Code Online (Sandbox Code Playgroud) 给定一个具有两个分支的仓库,每个分支具有独立的提交:
Branch Commits
------ -----------
final: e-g-i
/ \
master: a-b-c-d-f-h-?
Run Code Online (Sandbox Code Playgroud)
上表中的字母是有意义的:即“ master”和“ final”正在同时开发中,并且必须保留两个分支中的提交。
它是更好(更安全)合并的“主人”到“最后”,然后合并这回“主人”?还是将直接从“最终”合并到“主”中的提交保留在那里?
我知道合并冲突可能会出现。我更担心的是,在将“ final”合并到“ master”之后,我们不会丢失任何提交给“ master”的代码。
我发现了一些像这样的问题,但我找不到这个特别的问题.我有一些初始化为的字符串
NSString *string = [[NSString alloc] init];
Run Code Online (Sandbox Code Playgroud)
然后根据if/else块的结果为其分配值:
if ([anotherThing isEqualToString:@"boogers"]) {
string = [NSString stringWithFormat:@"some characters"];
} else {
string = [NSString stringWithFormat:@"some _other_ characters"];
}
Run Code Online (Sandbox Code Playgroud)
然后string在方法的后面使用.
如何在不在alloc/init阶段留下死存储的情况下完成此操作?如果我在if(或else)中分配,那么当我需要几行时,字符串就消失了.