我收到以下代码的编译错误:
if(true)
int a = 10;
else
int b = 20;
Run Code Online (Sandbox Code Playgroud)
如果我将其更改为以下代码,则没有编译错误:
if(true) {
int a = 10;
}
else {
int b = 20;
}
Run Code Online (Sandbox Code Playgroud)
为什么第一种语法错误,而且语言标准是什么?
在vim中,很容易找到一个文件而不知道该文件所在的目录.执行":args**/file.hpp"如果文件存在,它将打开它.
Emacs中是否有替代方法?查找文件似乎适用于通配符,但它不像vim那样棘手**.
我的功能如下:
foo :: Int -> a -> [a]
foo n v = bar n
where
bar :: Int -> [a]
bar n = take n $ repeat v
Run Code Online (Sandbox Code Playgroud)
使用ghci报告此错误:
Couldn't match type `a' with `a1'
`a' is a rigid type variable bound by
the type signature for foo :: Int -> a -> [a] at hs99.hs:872:1
`a1' is a rigid type variable bound by
the type signature for bar :: Int -> [a1] at hs99.hs:875:9
Expected type: [a1]
Actual type: …Run Code Online (Sandbox Code Playgroud)