Question

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

enter image description here

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top