I've seen Ruby code in which there are only two doub开发者_如何学Gole quotes ("") on a line. What does that line do?
I assume you might have seen a code like this.
def some_method
#do some operations
""
end
In this context, it means that the method is returning an empty string. In Ruby, the last evaluated operation in a method is what is returned from that method. So in this case, it returns an empty string literal.
Two double quotes represent an literal empty string in Ruby. And in many other languages.
精彩评论