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:
range1 = ( 0 .. 10 )
puts range1.hash()
|
Output:
2205001427131717671
Example 2:
range1 = ( 3 .. 6 )
puts range1.hash()
|
Output:
-377246730583736123
Last Updated :
19 Mar, 2024
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...