简体   繁体   中英

Coffeescript invalid syntax

Thoughts on why the following is invalid syntactically?

@foo(@bar('/test', {
      password
      username
      _method: 'GET'
    }
  )
)

The problem is the indentation.

The second parenthesis couldn't be read properly. If you make an indent explicitly for it, it work.

@foo(
  @bar('/test', {
      password
      username
      _method: 'GET'
    }
  )
)

Or remove indentation of the closing parenthesis.

@foo(@bar('/test', {
    password
    username
    _method: 'GET'
  }
))

both of them works as

this.foo(this.bar('/test', {
  password: password,
  username: username,
  _method: 'GET'
}));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM