日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ruby hash方法_Ruby中带有示例的Hash.rehash方法

發布時間:2025/3/11 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ruby hash方法_Ruby中带有示例的Hash.rehash方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ruby hash方法

Hash.rehash方法 (Hash.rehash Method)

In this article, we will study about Hash.rehash Method. The working of the method can't be assumed because of it's quite a different name. Let us read its definition and understand its implementation with the help of syntax and program codes.

在本文中,我們將研究Hash.rehash方法 。 由于該方法的名稱完全不同,因此無法進行假設。 讓我們閱讀其定義并在語法和程序代碼的幫助下了解其實現。

Method description:

方法說明:

This method is a Public instance method and belongs to the Hash class which lives inside the library of Ruby language. This method works in a way that constructs a new hash object which is based on the current hash object values for individual keys. If there is a change introduced in the hash object after they are declared then this method will do a re-indexing of the keys in the hash. You will have to face a run time error if you are trying to invoke this function during the process of traversing the hash instance.

此方法是Public實例方法,屬于Hash類,它位于Ruby語言庫中。 此方法以構造新哈希對象的方式工作,該對象基于單個鍵的當前哈希對象值。 如果聲明了哈希對象后引入了更改,則此方法將對哈希中的鍵進行重新索引。 如果在遍歷哈希實例的過程中嘗試調用此函數,則將面臨運行時錯誤。

Syntax:

句法:

Hash_object.rehash

Argument(s) required:

所需參數:

This method does not require any arguments.

此方法不需要任何參數。

Example 1:

范例1:

=beginRuby program to demonstrate Hash.rehash method =enda = ["Satyam","Amisha"] b = ["Nikhil","Saksham"]hsh = {a=>"friends", b=>"friends"}puts "Hash elements are: #{hsh}"puts "Hash.rehash implementation"b[0]="Hrithik"puts "Hash after rehash: #{hsh.rehash}"

Output

輸出量

Hash elements are: {["Satyam", "Amisha"]=>"friends", ["Nikhil", "Saksham"]=>"friends"} Hash.rehash implementation Hash after rehash: {["Satyam", "Amisha"]=>"friends", ["Hrithik", "Saksham"]=>"friends"}

Explanation:

說明:

In the above code, you can observe that you can rehash a hash object with the help of the Hash.rehash() method. We have inserted a new element inside the hash and replaced the current one. We got the result after rehashing the hash instance. This method is not creating changes in the original hash because this method is an example of non-destructive methods where the changes created by the method are not permanent.

在上面的代碼中,您可以觀察到可以借助Hash.rehash()方法重新哈希一個哈希對象。 我們在哈希表中插入了一個新元素,并替換了當前元素。 重新哈希哈希實例后,我們得到了結果。 此方法不會在原始哈希中創建更改,因為此方法是非破壞性方法的示例,在該示例中,該方法創建的更改不是永久的。

Example 2:

范例2:

=beginRuby program to demonstrate Hash.rehash method =enda = ["Satyam","Amisha"] b = ["Nikhil","Saksham"]hsh = {a=>"friends", b=>"friends"}puts "Hash elements are: #{hsh}"puts "Hash.rehash implementation"hsh.each do |key,value| hsh.rehash endputs "Hash after rehash: #{hsh.rehash}"

Output

輸出量

Hash elements are: {["Satyam", "Amisha"]=>"friends", ["Nikhil", "Saksham"]=>"friends"} Hash.rehash implementation rehash during iteration (repl):14:in `rehash' (repl):14:in `block in <main>' (repl):14:in `each' (repl):14:in `<main>'

Explanation:

說明:

In the above code, you can observe that when we are trying to rehash the hash instance during iteration then the method is throwing an exception named RuntimeError. This simply shows that you can’t rehash a hash during the process of iteration.

在上面的代碼中,您可以觀察到,當我們嘗試在迭代過程中重新哈希該哈希實例時,該方法將拋出一個名為RuntimeError的異常。 這僅表明您無法在迭代過程中重新哈希。

翻譯自: https://www.includehelp.com/ruby/hash-rehash-method-with-example.aspx

ruby hash方法

總結

以上是生活随笔為你收集整理的ruby hash方法_Ruby中带有示例的Hash.rehash方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美高清性xxxxhdvideosex | 图片一区二区 | 免费一级淫片aaa片毛片a级 | 国产精品白丝喷水在线观看 | 1024福利| 欧美大色网 | 免费国产精品视频 | 亚洲综合图片网 | 夜夜av| 草民午夜理伦三级 | 国产欧美一区二区精品性色超碰 | 天天干天天操天天爱 | 久久高清毛片 | 经典毛片 | 九九小视频 | 亚洲另类自拍 | 一级特黄bbbbb免费观看 | 欧美日韩八区 | 亚洲国产精品一区二区尤物区 | 精品一区二区三区四 | 99热视| 久久精品视频偷拍 | 尤物在线免费观看 | 一区二区国产在线观看 | 国产一级免费大片 | 插插插av | 99思思| 久久精品成人一区二区三区蜜臀 | 免费观看黄色小视频 | 欧美三级在线看 | 粉嫩av懂色av蜜臀av分享 | 久草免费在线视频 | 亚洲 欧洲 日韩 | 国产夜色精品一区二区av | 五月天婷婷基地 | 中文字幕亚洲激情 | 日韩网站在线观看 | 波多野结衣电影在线播放 | 北条麻妃二三区 | 国产高潮在线观看 | 成年人视频免费 | 国产一级视频在线 | 超碰91人人 | 日韩大片一区二区 | 亚洲双插 | 人妻精品一区一区三区蜜桃91 | 好爽又高潮了毛片 | www.com久久 | 99热在线观看免费精品 | 欧美性生活精品 | 麻豆传媒在线观看 | 日韩精品一区二区在线视频 | 男女插孔视频 | 国产精品二区一区 | 熟女少妇一区二区三区 | 国产色a | 亚洲天堂一区在线观看 | 国产精品国产三级国产aⅴ中文 | 亚洲最大免费视频 | 蜜桃精品久久久久久久免费影院 | 亚洲私拍| 一区免费在线 | 免费观看黄色 | 夜夜夜网站 | 天天爽天天插 | 亚洲啪av永久无码精品放毛片 | 色综合久久88色综合天天免费 | 亚洲国产精品综合 | 免费久久 | 久久香蕉影视 | 一级做a视频 | 国产99在线观看 | 一区二区在线免费看 | 不卡av免费在线观看 | 亚洲av无码乱码在线观看性色 | 三上悠亚久久精品 | 蜜桃久久久久久 | 网站免费视频www | 精品人人妻人人澡人人爽牛牛 | 肉丝袜脚交视频一区二区 | 国产精品一区二区三区在线免费观看 | 国产精品女同 | 日韩国产欧美一区二区三区 | 天堂在线观看免费视频 | 国产精品久久久久久久久久妞妞 | 亚洲日本japanese丝袜 | 天天干天天弄 | 999这里只有精品 | 成人三级图片 | 精品成在人线av无码免费看 | 久操热线| 人人综合 | 亚洲成人a√ | 精品国产一区二区三区在线观看 | 免费国产精品视频 | 日日操夜夜爽 | 色久阁| 午夜小网站| www婷婷av久久久影片 |