Complete the code to write the string 'Hello' to a file named 'greeting.txt'.
File.[1]('greeting.txt', 'Hello')
The File.write method writes the given string to the specified file.
Complete the code to write 'Ruby is fun!' to a file named 'fun.txt'.
File.[1]('fun.txt', 'Ruby is fun!')
File.write writes the string to the file, replacing any existing content.
Fix the error in the code to write 'Data' to 'data.txt'.
File.[1]('data.txt', 'Data')
File.write is the correct method to write data to a file. puts and gets are for console input/output.
Fill both blanks to write the string length of 'hello' to 'length.txt'.
File.[1]('length.txt', 'hello'.[2].to_s)
File.write writes to the file, and size returns the length of the string.
Fill all three blanks to write uppercase words longer than 3 letters from the list to 'output.txt'.
words = ['cat', 'elephant', 'dog', 'lion']\nFile.write('output.txt', words.select { |word| word.[2] [3] 3 }.map { |word| word.[1] }.join("\n"))
upcase converts words to uppercase, length gets the word length, and > checks if length is greater than 3.