You’re probably familiar with __LINE__ keyword in Ruby. Wherever it’s used, it refers to the line number in the current file. It says so right here in the Ruby docs.
QUICK! What’s the output of the following code?
CODE:
#!/usr/bin/env ruby
class LineDemo
def self.process(text, lineno)
# do important processing on text
puts lineno
end
end
LineDemo.process <
Here is some text on which we will do some important processing.
Here, also, is some important text to process.
TEXT
# All done!The answer is obvious. Of course, it prints 13.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-744849/
,如需转载,请注明出处,否则将追究法律责任。