About 90,800 results
Open links in new tab
  1. How to initialize an array in one step using Ruby?

    Apr 21, 2011 · For arrays of whitespace-delimited strings, you can use Percent String syntax: You can also pass a block to Array.new to determine what the value for each entry will be:

  2. Create array from string in ruby - Stack Overflow

    Sep 16, 2015 · I want to create array with data from this string that will look like this: first key in array is selected option and the second one is correct option. Is there any way to do it with …

  3. Working With Ruby Strings & Arrays - RubyGuides

    Both strings & arrays are very important building blocks for writing your Ruby programs. If you don’t understand how these 2 work you won’t be able to write even the most basic projects …

  4. Ruby - String Array Examples - Dot Net Perls

    Create string arrays. Here we use 2 syntax forms to create string arrays. First, we use the initializer syntax—this requires only one line to create a 3-element array.

  5. How to initialize array in Ruby - GeeksforGeeks

    Oct 24, 2019 · In this article, we will learn how to initialize the array in Ruby. There are several ways to create an array. Let’s see each of them one by one. Using the new class method: new …

  6. Ruby Language Tutorial => Create Array of Strings

    Arrays of strings can be created using ruby's percent string syntax: This is functionally equivalent to defining the array as: Instead of %w() you may use other matching pairs of delimiters: …

  7. Making an array of strings - Ruby - Ruby-Forum

    Sep 11, 2011 · how do I do that in Ruby? array = %w ( boy girl cat dog ) Also, I want to read words from a file and make them an array of strings. I can read files fine but making an array …

  8. Ruby String Array Examples - The Developer Blog

    With a string array, we can handle each word separately (with no parsing steps). In Ruby we often prefer iterators, not loops, to access an array's individual elements. String Array Create string …

  9. How to Declare a String Array in Ruby - Python Examples

    To declare a string array in Ruby, you can use array literal syntax or create an empty array and then add string elements to it.

  10. create an array of string in Ruby - Code Snippets with explanation

    Jan 11, 2023 · This code creates an array of strings in Ruby. First, the name of the array is defined as “my_array”. Then within the brackets, three strings are included, “string1”, “string2”, …

  11. Some results have been removed