红宝石 |可枚举条目()函数
enumerable的entries()是 Ruby 中的一个内置方法,它返回 enumerable 中的项目。
Syntax: enu.entries
Parameters: The function does not takes any parameter.
Return Value: It returns the items in the enum.
示例 1 :
# Ruby program for entries method in Enumerable
# Initialize
enu = [7, 9, 10]
# Prints each with object
enu.entries
输出:
[7, 9, 10]
示例 2 :
# Ruby program for entries method in Enumerable
# Initialize
enu = (7..14)
# Prints each with object
enu.entries
输出:
[7, 8, 9, 10, 11, 12, 13, 14]