小编Oru*_*rup的帖子

if语句中的Java变量范围

我收到以下代码的编译错误:

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)

为什么第一种语法错误,而且语言标准是什么?

java syntax-error

33
推荐指数
4
解决办法
3811
查看次数

如何在没有已知确切目录的情况下在Emacs中查找文件?

在vim中,很容易找到一个文件而不知道该文件所在的目录.执行":args**/file.hpp"如果文件存在,它将打开它.

Emacs中是否有替代方法?查找文件似乎适用于通配符,但它不像vim那样棘手**.

emacs

14
推荐指数
3
解决办法
1万
查看次数

功能无法匹配类型

我的功能如下:

    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)

haskell types type-inference

6
推荐指数
1
解决办法
990
查看次数

标签 统计

emacs ×1

haskell ×1

java ×1

syntax-error ×1

type-inference ×1

types ×1