小编Tec*_*oCF的帖子

CoffeeScript编译:意外的IF

我正在为API编写一些CoffeeScript代码,在我的代码的错误捕获部分中,我放置了一个IF语句.现在,在编译过程中,CoffeeScript说IF语句是意外的.

#  Handle Errors
app.error (err, req, res, next) ->
    if err instanceof NotFound
        res.send '404, not found.'
    else
        res.send '500, internal server error.'

app.get '/*', (req, res) ->
    throw new NotFound

NotFound = (msg) ->
    this.name = 'NotFound'
    Error.call this, msg
    Error.captureStackTrace this, arguments.callee
Run Code Online (Sandbox Code Playgroud)

错误是

/home/techno/node/snaprss/application.coffee:22:5: error: unexpected if
    if err instanceOf NotFound
    ^^
Run Code Online (Sandbox Code Playgroud)

有没有人有任何想法在我的代码中的问题?

javascript coffeescript

7
推荐指数
1
解决办法
8161
查看次数

如何在 C# 中获取 string[] 数组的一部分

如何使用 C# 从另一个包含旧 string[] 数组子部分的 string[] 创建一个新 string[]?

例如,如果我有:

string[] a = { "cat", "dog", "hamster", "parrot" }
Run Code Online (Sandbox Code Playgroud)

我想在我应该得到的第一个元素之后得到一切:

string[] b = { "dog", "hamster", "parrot" }
Run Code Online (Sandbox Code Playgroud)

如果没有 for 循环这甚至是可能的,我如何实现这一点?

.net c# arrays collections

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

标签 统计

.net ×1

arrays ×1

c# ×1

coffeescript ×1

collections ×1

javascript ×1