Home
Ruby
ActiveRecord
Array
CGI
Class
Collections
Database
Date
Design Patterns
Development
File Directory
GUI
Hash
Language Basics
Method
Network
Number
Rails
Range
Reflection
Statement
String
Threads
Time
Tk
Unit Test
Windows Platform
XML
Menu
Creating Hashes : Hash.new « Hash « Ruby
Ruby
Hash
Hash.new
Creating Hashes
# You can create an empty hash with the
new
class
method. months = Hash.new
Related examples in the same category
1.
You can test to see if a hash is empty with empty?
2.
Test how big it is with length or size
3.
use new to create a hash with a default value which is otherwise just nil
4.
access any key in a hash that has a default value
5.
Hash with =>
6.
Hash.new with block logic
7.
This lazily initialized hash maps integers to their factorials