-4

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

Community
  • 1
  • 1
amir amir
  • 3,375
  • 7
  • 26
  • 29
  • params in square brackets are optional – NARKOZ Aug 14 '11 at 17:02
  • I'm voting to close this question as "not a real question", as you haven't explained which part you don't understand. However, for future reference, please don't paste text in an image - it makes it unreadable for visually impaired readers, and impossible to machine translate. – Andrew Grimm Aug 15 '11 at 00:03

1 Answers1

1

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.

Mladen Jablanović
  • 43,461
  • 10
  • 90
  • 113
  • Excuse me , what is the return of first,second,third,fourth form of open ? – amir amir Aug 14 '11 at 19:15
  • It would be helpful if you would give the URL from which you pasted the screenshot. Anyway, forms without block (first two) return the file handle object (of `File` class), and block forms (latter two) return anything the block iself returns. – Mladen Jablanović Aug 14 '11 at 19:20
  • Mladen Jablanović , I am so thankful from you.I take this screen shot from ruby documentation that installed with ruby 1.9.2 p180, do you know a better documentation ? – amir amir Aug 14 '11 at 19:29