Ruby Quick Reference

Quick reference for efficient coding

View the Project on GitHub YumaYX/RubyQuickReference

read.rb(file)

This Ruby code uses the File.read method to read the contents of a file named ‘filewr.txt’ and returns the content as a string.

Execution:

File.read('filewr.txt')
#=> "Hello"

Executed with Ruby 3.3.5