I am new with Ruby and I don't understand ruby Documentation.I cut a piece of ruby documentation开发者_如何转开发. please explain completely this piece. thanks
These are signatures of File#open
method. As Ruby doesn't support method overloading, there is just one such method, but accepting different combinations of arguments (and potentially returning different things).
And to clarify the syntax, the first form in your screenshot:
open(filename, mode='r'[, opt]) -> file
means that the first form of File#open
method expects following arguments:
- filename (mandatory)
- mode (optional, with default value
'r'
) - opt (probably a hash supporting different additional options)
and that it returns a file object.
精彩评论