Topics

Ruby

About this topic: Articles tagged __TAG__

Showing 109 articles

Topics

Articles

Showing 109 articles

How-tos How to Convert a String to Lowercase or Uppercase in Ruby Learn how Ruby's downcase, upcase, downcase!, and upcase! methods convert strings, how they differ, and how to check a string's case. How-tos How to Add an Item to a Ruby Hash Learn how to add or update entries in a Ruby Hash with `[]`, `merge`, `merge!`, and `store`. How-tos How to Use the inject Method in Ruby Learn how Ruby's inject method carries an accumulator through a collection to sum values, build hashes, transform strings and objects, and collect matches. How-tos Difference Between puts and print in Ruby Compare how Ruby's puts and print handle newlines, multiple arguments, and arrays, with examples to help choose between line-oriented and continuous output. How-tos How to Read Lines from a File in Ruby Learn how to read lines from a file in Ruby using two effective methods: File.readlines and File.foreach. This guide provides clear code examples and detailed explanations to help … How-tos How to Parse XML With Ruby Parse XML in Ruby with Nokogiri, select elements with XPath or CSS, read text and attributes, and write document changes. How-tos The send Method in Ruby Learn how Ruby's `send` invokes methods dynamically, passes arguments and returns values, and how to select methods safely while understanding visibility. How-tos How to Change Ruby Version on Mac Learn how to change the Ruby version on your Mac with rbenv or RVM, choose a project-specific version, and verify which Ruby your shell uses. How-tos How to Write Multi-Line String in Ruby Learn how to write multi-line strings in Ruby with this comprehensive guide. Explore various methods including heredoc, string interpolation, array join, and concatenation, each … How-tos Enum in Ruby This article explores how to use enums in Ruby, detailing their definition, advantages, and best practices. Learn to enhance your code readability and maintainability by managing … How-tos How to Get Object Type using kind_of, instance_of, and is_a In Ruby This article explores how to check the type of an object in Ruby using the methods kind_of?, instance_of?, and is_a?. Learn the differences between these methods with clear … How-tos for vs each in Ruby Explore the differences between for and each in Ruby in this comprehensive guide. Discover when to use each iteration method, their syntax, performance considerations, and how they … How-tos How to Accept User Input With Gets in Ruby This tutorial explains how to accept user input with gets and sanitize with chomp in Ruby. Learn the essential techniques for capturing and validating user input, ensuring your … How-tos How to Write to a File in Ruby This article shows how to write to a file in Ruby, exploring methods like File.open, File.write, and IO How-tos How to Update Ruby Version in macOS This article shows how to update Ruby version in macOS using Homebrew, Rbenv, and RVM. Learn the steps to manage Ruby versions effectively, ensuring compatibility with the latest … How-tos How to Parse a JSON String in Ruby This article provides a comprehensive guide on how to parse a JSON string in Ruby. Learn about the built-in JSON library, error handling, and working with nested structures to … How-tos require vs include in Ruby Explore the differences between require and include in Ruby with this comprehensive guide. Learn how to effectively use each method to manage dependencies and share functionality … How-tos How to Use the call() Method in Ruby This article explains how to use the call method in Ruby, focusing on its application with procs and lambdas. You'll learn how to invoke these closures effectively, understand … How-tos How to Use Safe Navigation in Ruby This tutorial illustrates how to utilize safe navigation in Ruby, a feature that simplifies accessing object properties without raising errors. Learn about the safe navigation … How-tos How to Handle Exceptions Using Begin and Rescue in Ruby This article discusses how to handle exceptions using begin and rescue in Ruby. Discover the basics of exception handling, learn to manage multiple exceptions, ensure cleanup with … How-tos Difference Between Class and Class Instance Variables in Ruby This article explores the difference between class and class instance variables in Ruby. Understand their unique characteristics, use cases, and how to leverage them effectively in … How-tos How to Generate Random Number in Ruby This tutorial provides a comprehensive guide on how to generate random numbers in Ruby. Learn about the different methods available, including using the Random class and … How-tos Difference Between Each_with_index and each.with_index in Ruby This tutorial explores the difference between each_with_index and each.with_index in Ruby. Learn how to iterate through arrays while accessing element indices, complete with code … How-tos The Binary Left Shift Operator in Ruby This article introduces the binary left shift operator (<<) in Ruby, explaining its syntax, practical applications, and how it enhances coding efficiency. Discover how to …

← All topics