Ruby: I/O Flashcards

1
Q

How do you create a new file?

A

Ruby has a built in class called File. So it follows the same rules as creating an instance of a class. For example:

(instance of a class)
class Person
end

person = Person.new(“James”)

Example for file:

file = File.new(“filename”, “r”)

r* is example

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

mode strings: read

A

r

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

mode string: write

A

w

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

mode string: read and write

A

r+

How well did you know this?
1
Not at all
2
3
4
5
Perfectly