YoVDO

Intermediate Ruby Programming and Control Structures

Offered By: Packt via Coursera

Tags

Ruby Courses Control Structures Courses Recursion Courses String Manipulation Courses

Course Description

Overview

Save Big on Coursera Plus. 7,000+ courses at $160 off. Limited Time Only!
This course is designed for those with a foundational understanding of Ruby seeking to elevate their skills. - It begins with string operations, exploring differences between single and double quotes, multi-line strings, and string concatenation, while also covering string comparisons and manipulations. - Control structures are introduced next, including various loops and conditional statements with practical examples like the FizzBuzz problem. - You'll learn to implement while and until loops, use keywords like next and break, and delve into recursion. - The final sections cover debugging and advanced array methods, teaching you to use tools like the debugger and binding.break, and exploring array iteration methods like each, map, and select. - You'll also cover ranges, strings, Hashes and explore how object references and copies work in Ruby. The course is ideal for developers with basic Ruby knowledge looking to deepen their expertise and improve problem-solving abilities. This approach combines theoretical explanations with practical applications, featuring hands-on coding exercises and real-world examples.

Syllabus

  • Strings I
    • In this module, we will delve into the intricacies of handling strings in Ruby. You will learn the differences between single and double quotes, how to create multiline strings with here documents, and perform string comparisons using equality and inequality operators. We'll explore different methods for concatenation, understand indexing to access and modify string characters, and apply various string methods like 'length', 'empty'?, 'capitalize', 'reverse', and bang methods for mutating strings directly. By the end of this module, you'll have a comprehensive understanding of string operations in Ruby.
  • Loops
    • In this module, we will explore various looping constructs in Ruby. You will learn the syntax and usage of the 'while' and 'until' loops, understanding how they execute based on conditional statements. We will tackle the FizzBuzz problem, a popular beginner coding challenge, and walk through its solution. Additionally, we will introduce control flow keywords such as 'next' and 'break', and delve into recursion, where methods call themselves to solve problems. By the end of this module, you will be adept at using loops and recursion to manage repetitive tasks and complex problem-solving in Ruby.
  • Debugging
    • In this module, we will focus on debugging techniques in Ruby. You will learn to import and use the debug library to establish breakpoints with 'debugger' or 'binding.break', allowing you to pause execution and examine the program's state. We will cover the 'step' keyword to progress through code line by line and demonstrate how to use the 'info' keyword to list all variables and parameters. By combining these techniques, you will gain a thorough understanding of how to troubleshoot and resolve issues in your Ruby programs effectively.
  • Arrays I: Creation and Access
    • In this module, we will introduce you to arrays, a fundamental data structure in Ruby for storing ordered elements. You will learn how to create arrays, including nested arrays for multidimensional data structures. We'll cover different ways to access and overwrite array elements using square bracket syntax, the 'fetch' method, and methods like 'first', 'last', and 'values_at'. You'll also explore methods to evaluate array properties such as 'length', 'size', and 'empty'?, and compare arrays using equality, inequality, and the spaceship operator. Additionally, we'll dive into methods for adding and removing elements like 'push', 'pop', 'shift', 'unshift', and 'insert'. By the end, you'll have a comprehensive understanding of array creation, access, and manipulation in Ruby.
  • Ranges
    • In this module, we will explore ranges in Ruby, an object that represents a sequence of numbers or letters. You'll learn to create numeric and alphabetical ranges and understand the rules of inclusivity and exclusivity using two and three dots. We will cover methods like 'include'? and 'member'? to check if a value exists within a range, and use the 'rand' method to generate random numbers. Additionally, you'll see how to extract sequences from strings or arrays using ranges, and incorporate ranges into case statements for efficient logic handling. Finally, we'll convert ranges to arrays using the 'to_a' method, giving you versatile tools for working with sequential data in Ruby.
  • Arrays II: Iteration and Various Methods
    • In this module, we will dive deeper into array operations, focusing on iteration and advanced methods. You will learn to use the 'each' and 'each_with_index' methods for sequential element traversal, and how to nest 'each' method calls for more complex operations. We'll explore using traditional 'for' loops and alternatives like 'while' and 'until' loops for array iteration. Methods such as 'map', 'collect', 'select', 'reject', and 'partition' will be introduced to transform and filter arrays based on conditions. You will also learn to query arrays with methods like 'any?', 'all?', 'find', 'detect', 'index', 'include?', 'max', and 'min', and understand how to handle unlimited method arguments using the splat operator. By the end of this module, you'll have a comprehensive toolkit for effectively managing and manipulating arrays in Ruby.
  • Strings II
    • In this module, we will continue exploring advanced string manipulation techniques in Ruby. You will learn to use the 'split' method to divide strings into arrays based on specified delimiters and the 'join' method to merge array elements back into a single string. We will cover iterating over string characters with the 'chars' and 'each_char' methods, and converting strings to arrays for iteration. Additionally, you'll learn to count occurrences of substrings with the 'count' method, find positions of substrings using 'index' and 'rindex', and remove characters from strings with the 'delete' method. By the end of this module, you'll have a robust set of tools for handling and manipulating strings in your Ruby programs.
  • Object References and Copies
    • In this module, we will explore how object references and copies work in Ruby. We will then cover the 'dup' and 'clone' methods, which create copies of objects, isolating them from changes made to the source object. The 'freeze' method will be introduced to make objects immutable, ensuring their state cannot be altered. Additionally, we'll discuss how passing objects to methods can lead to mutations and how to manage these changes effectively. By the end of this module, you will have a solid understanding of object references, copying, and immutability in Ruby.
  • Hashes I
    • In this module, we will introduce you to hashes, a versatile data structure for associating keys with values. You will learn how to create and manipulate hashes using various syntaxes, including hash rockets and shorthand notations with symbols as keys. We will cover methods for adding, iterating over, and checking the inclusion of key-value pairs, as well as extracting subsets, converting between hashes and arrays, and removing pairs. Additionally, you will explore advanced operations like merging hashes and creating hashes with default values, while addressing potential reference issues. By the end, you'll be proficient in creating, managing, and manipulating hashes in Ruby.
  • Arrays III: Bonus Methods
    • In this module, we will explore advanced array methods that provide powerful ways to manipulate and transform arrays in Ruby. You'll learn to reverse and sort arrays, remove duplicates with 'uniq', and eliminate 'nil' values using 'compact'. We will cover aggregation methods like 'inject' and 'reduce', as well as methods to flatten nested arrays. Additionally, you'll learn to extract random elements with 'sample', repeat elements using the asterisk operator, merge arrays while excluding duplicates, subtract elements, and find intersections between arrays with the '&' operator. By the end, you'll be adept at using these advanced methods to handle and manipulate arrays efficiently in your Ruby programs.

Taught by

Packt - Course Instructors

Related Courses

Learn Ruby
Codecademy
Comandos de Ruby para Devops
Coursera Project Network via Coursera
Introduction to Computer Science and Programming
Tokyo Institute of Technology via edX
Advanced Ruby Programming and Object-Oriented Design
Packt via Coursera
Ruby Fundamentals and Basic Programming Concepts
Packt via Coursera