HomeSearch

Ruby Pages

Dot Net Perls has example pages for many languages, with explanations and code side by side (for easy understanding).
C#F#GoJavaJSPythonRubyScalaSwiftVB.NETWindowsWPF
Iterator. Test and benchmark iterators. Use times, upto, downto, step and each in programs.Ruby Iterator: Times, Step Loops
2D array. Use 2D arrays and jagged arrays. Nest arrays and access subarrays.Ruby 2D Array Examples
Array. Use arrays: add elements, change elements and test arrays with loops and iterators.Ruby Array Examples
Case. Use the case statement. Match values, and ranges of values, with this statement.Ruby Case Examples: Ranges, Strings and Regexp
Console. Use the console window. Call the puts, p, print and stdin.readline methods.Ruby Console: Puts, Print and stdin
Convert. Cast and converts types: use methods to convert strings, arrays and hashes.Ruby Convert Types: Arrays and Strings
DateTime. Use the DateTime class. Compute and manipulate dates and times.Ruby DateTime Examples: require date
Exceptions. Handle exceptions. Use begin, rescue and ensure to enter protected regions.Ruby Exception Examples: Begin and Rescue
Files. Handle files: open a file with File.open and sequentially read in each line until eof.Ruby File Handling: File and IO Classes
Format. Use the format string syntax. See examples for formatting values in many ways.Ruby Format String Examples
Hash. Use the Hash class to store keys and values. Hash enables fast lookups.Ruby Hash Examples
If. Use the if-statement, elsif and else. See the unless statement.Ruby If Examples: Elsif, Else and Unless
Keywords. Review a list of keywords in Ruby. These keywords are used in nearly all programs.Ruby Keywords
Math. Use mathematical functions like floor, ceil and truncate. Compute square roots.Ruby Math Examples: floor, ceil, round and truncate
Nil. Test values against nil, with an if, to avoid errors like NoMethodError.Ruby Nil Value Examples: NoMethodError
Numbers. Use numbers and the zero and eql methods. Convert strings into Integers and Floats.Ruby Number Examples: Integer, Float, zero and eql
Rand, random numbers. Generate random numbers with rand. Use srand to seed a random stream.Ruby Random Number Generator: rand, srand
Regexp. Use the Regexp class, which processes text. Call the match and split methods.Ruby Regexp Match Method
Remove duplicates. Use the uniq method to remove duplicate elements from arrays with minimal code.Ruby Remove Duplicates From Array
Sort. Use the sort method. Sort with blocks, sort in descending order and sort in-place.Ruby Sort Arrays (Use Block Syntax)
Split. Call the split method to separate strings. Use string and regular expression delimiters.Ruby Split String Examples
String. Use strings: create literals, manipulate strings and use each char and each line.Ruby String Examples (each char, each line)
Sub, gsub. Use sub and gsub to replace strings. Regular expressions are used for complex replacements.Ruby Sub, gsub: Replace String
Substring. Get substrings with ranges and indexes. Regular expressions can be used to get substrings.Ruby Substring Examples
While. Loop over ranges of numbers. See the while-loop, until-loop and other loops.Ruby While, Until and For Loop Examples
© 2007-2019 Sam Allen. Every person is special and unique. Send bug reports to info@dotnetperls.com.
Home
Dot Net Perls