Ruby | Range hash() function
The hash() is an inbuilt method in Ruby returns a hash-code for the given range. The hash-value will vary for every execution.
Syntax: range1.hash()
Parameters: The function accepts no parameter.
Return Value: It returns a hash-code for the given range.
Example 1:
# Ruby program for hash() # method in Range # Initialize range range1 = (0..10) # Prints hash value puts range1.hash() |
chevron_right
filter_none
Output:
2205001427131717671
Example 2:
# Ruby program for hash() # method in Range # Initialize range range1 = (3..6) # Prints hash value puts range1.hash() |
chevron_right
filter_none
Output:
-377246730583736123
Recommended Posts:
- Ruby | Hash key?() function
- Ruby | Hash any?() function
- Ruby | Hash each() function
- Ruby | Hash key() function
- Ruby | Hash dig() function
- Ruby | Hash eql? function
- Ruby | Hash fetch_values() function
- Ruby | Hash include?() function
- Ruby | Hash flatten() function
- Ruby | Hash compare_by_identity () function
- Ruby | Matrix hash() function
- Ruby | Regexp hash() function
- Ruby | Hash compact!() function
- Ruby | Hash clear() function
- Ruby | Hash assoc() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



