Syntax
Ruby Require a Library Syntax
In Ruby, require a library: loads a library or file — require "json"
Quick Answer
- Syntax
require "json"
RubySyntax
Require a Library
Code example
require "json"
Loads a library or file.
How to require a library in Ruby
- Open your Ruby file or editor.
- Copy the example, then replace its sample names and values for your code.
Ruby Require a Library Syntax
Use require "json".
Related Syntax References
Frequently asked questions
What is the Ruby syntax for require a library?
Use this pattern: require "json"
Can I copy this Ruby code example?
Yes. Use Copy code and adapt the example to your program.
Is this Ruby syntax different on Mac or Windows?
No. The language syntax is the same across operating systems.
Official source · How we verify