如何在CoffeeScript中发表评论? "/*此*/"不起作用 [英] How do I comment in CoffeeScript? "/* this */" doesn't work

查看:91
本文介绍了如何在CoffeeScript中发表评论? "/*此*/"不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以用什么方式在CoffeeScript中发表评论?

In what ways can you comment in CoffeeScript?

文档说您可以使用三个哈希符号来启动和关闭注释块:

The documentation say you can use three hash symbols to start and close a comment block:

###
  Comments
  go
  here
###

我发现我有时可以使用以下两种格式

I've found that I can sometimes use the following two formats

`// backticks allow for straight-JavaScript,
 // but the closing backtick can't be on a comment line (I think?)
`

有没有更简单的方法在CoffeeScript中插入简短注释?

Are there a simpler way to insert short comments in CoffeeScript?

请勿使用此样式**

由于这引起了很多关注,我想强调一下

Since this is getting a lot of views, I want to emphasize that

/* Comment goes here */

/*单独运行时,

会产生MATH错误.

produces a MATH error when the /* is on its own line.

正如特雷弗(Trevor)在对问题的评论中指出的那样,这是一个正则表达式不是一条评论!

As Trevor pointed out in a comment on the question, this is a regular expression, NOT a comment!

推荐答案

使用单个#号

# like this

一个字符似乎很小;)

也:

###
This block comment (useful for ©-Copyright info) also gets 
passed on to the browsers HTML /* like this! */
###

这篇关于如何在CoffeeScript中发表评论? "/*此*/"不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆