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

歡迎訪問 生活随笔!

生活随笔

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

编程问答

obj[]与obj._Ruby中带有示例的Array.rassoc(obj)方法

發布時間:2023/12/1 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 obj[]与obj._Ruby中带有示例的Array.rassoc(obj)方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

obj[]與obj.

Array.rassoc(obj)方法 (Array.rassoc(obj) Method)

In this article, we will study about Array.rassoc(obj) method. You all must be thinking the method must be doing something which is related to the insertion of a certain element. It is not as simple as it looks. Well, we will figure this out in the rest of our content. We will try to understand it with the help of syntax and demonstrating program codes.

在本文中,我們將研究Array.rassoc(obj)方法 。 大家都必須認為該方法必須執行與插入某個元素有關的操作。 它并不像看起來那么簡單。 好吧,我們將在其余內容中解決這個問題。 我們將嘗試借助語法并演示程序代碼來理解它。

Method description:

方法說明:

This method is Public instance method and belongs to the Array class which lives inside the library of Ruby language. This method is used to check whether an object is a part of the particular Array instance or not and that Array instance cannot be a normal Array instance. If it is not normal, it means that Array instance is the Array of multiple Array instances or you can say that it the collection of multiple objects which are itself an object of Array class. Basically, it works for the Array instances whose elements are also Array instances. Let us go through the syntax and demonstrating the program codes of this method.

該方法是Public實例方法,屬于Array類,它位于Ruby語言庫中。 此方法用于檢查對象是否為特定Array實例的一部分,并且該Array實例不能為普通Array實例。 如果不正常,則表示Array實例是多個Array實例的Array,或者可以說它是多個對象的集合,而這些對象本身就是Array類的對象。 基本上,它適用于其元素也是Array實例的Array實例。 讓我們來看一下語法,并演示該方法的程序代碼。

If you are thinking what it will return then let me tell you, it will return the first contained Array instance where it found the presence of the object. It will return "nil" if it hadn't found the object in any of the Arrays.

如果您在考慮它將返回什么,那么讓我告訴您,它將返回找到對象存在的第一個包含的Array實例。 如果未在任何數組中找到對象,它將返回“ nil”。

Syntax:

句法:

array_instance.assoc(obj)

Argument(s) required:

所需參數:

This method only takes one parameter and that argument is nothing but an object whose presence we want to check.

此方法僅使用一個參數,而該參數不過是一個要檢查其存在性的對象。

Example 1:

范例1:

=beginRuby program to demonstrate rassoc method =end# array declarations array1 = [1,"Ramesh","Apple",12,true,nil,"Satyam","Harish"] array2 = ["Akul","Madhu","Ashok","Mukesh",788] array3 = ["Orange","Banana","Papaya","Apricot","Grapes"] arraymain = [array1,array2,array3]puts "Enter the element you want to search" ele = gets.chompif arraymain.rassoc(ele) != nilputs "Element found in:"print arraymain.rassoc(ele) elseputs "Element not found" end

Output

輸出量

RUN 1: Enter the element you want to searchRamesh Element found in: [1, "Ramesh", "Apple", 12, true, nil, "Satyam", "Harish"]RUN 2: Enter the element you want to searchKiwi Element not found

Explanation:

說明:

In the above code, you can find that the Array instance on which we have invoked rassoc() method is not any normal Array instance. It is the collection of multiple Array instances. It is returning the whole Array instance where it has found the object inputted by the user.

在上面的代碼中,您可以發現我們調用rassoc()方法的 Array實例不是任何普通的Array實例。 它是多個Array實例的集合。 它返回找到用戶輸入對象的整個Array實例。

Example 2:

范例2:

=beginRuby program to demonstrate rassoc method =end# array declaration array1 = ["Babita","Sabita","Ashok"] puts array1.rassoc("Babita")

Output

輸出量

No Output.

Explanation:

說明:

In the above, you can verify that rassoc() method does not work upon normal Array instances. It will return nil even if the object is a part of the Array instance.

在上面,您可以驗證rassoc()方法不適用于普通Array實例。 即使對象是Array實例的一部分,它也將返回nil。

翻譯自: https://www.includehelp.com/ruby/array-rassoc-obj-method-with-example.aspx

obj[]與obj.

總結

以上是生活随笔為你收集整理的obj[]与obj._Ruby中带有示例的Array.rassoc(obj)方法的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 视频一区二区中文字幕 | 在线免费观看a视频 | 少妇被躁爽到高潮无码文 | 成人免费毛片东京热 | 欧美日韩国产中文 | 高清黄色一级片 | 国产毛片一区二区 | 色激情网 | 国产色爱| 日日干视频 | 美女xx00| 97在线免费公开视频 | 精品国产亚洲一区二区麻豆 | 91成年视频 | 欧美日韩毛片 | 日韩色图一区 | 成人污网站| 原来神马电影免费高清完整版动漫 | 中文字幕免费高清在线 | 外国黄色网址 | 乱熟女高潮一区二区在线 | 少妇真人直播免费视频 | 祥仔视觉av | 国产精品夜色一区二区三区 | 91精品国自产 | 97av在线 | 国产a一级片 | 深夜视频在线观看免费 | 欧美国产免费 | 亚洲视频一区 | 三级黄色小视频 | 五月天久久久 | 在线香蕉| 激情五月综合 | 欧美大片免费观看网址 | 国产在线精品一区二区 | 伊人国产一区 | 日本aⅴ视频 | 麻豆一区二区在线观看 | 亚洲激情欧美色图 | 99视频只有精品 | 欧美亚韩一区二区三区 | 少妇高潮灌满白浆毛片免费看 | 久久免费电影 | 扒丝袜| 国产人人爽 | 日本中文字幕有码 | 欧美性69 | 另类激情综合 | 中文字幕在线不卡视频 | 激情小说五月天 | 亚洲欧美成人综合 | 我们2018在线观看免费版高清 | 免费的黄色大片 | 麻豆射区 | 理论片av | 肥臀浪妇太爽了快点再快点 | 国产超碰人人爽人人做人人爱 | 精品自拍第一页 | 又黄又爽视频在线观看 | 特大巨交吊性xxxx | 久热av在线 | 99久久久国产精品无码免费 | 亚洲欧美日韩另类在线 | 亚洲精品黄色 | 无码国产精品一区二区色情男同 | 国产乱乱 | 国产欧美三级 | 91欧美日韩 | 国产乱人乱偷精品视频a人人澡 | 日日干夜夜撸 | 高清一区二区三区四区五区 | 欧美日韩一区二区三区四区 | 久久久久久久久久久影院 | 亚洲爽爽 | www.久久成人 | 日韩一级视频在线观看 | 中文字幕第一页在线播放 | 在线看片网址 | 人妻奶水人妻系列 | 成人a站 | 成年人精品 | 国产精品美女久久久久久久久 | 亚洲最大综合网 | 大陆农村乡下av | 婷婷一级片 | 午夜视频日韩 | 国产操人 | 欧美在线观看一区 | 销魂美女一区二区 | 国产成人麻豆免费观看 | 亚洲精品在线观看av | 先锋影音一区二区 | 成人午夜电影网站 | 黄色免费在线观看视频 | 操天天 | 精品伊人久久 | 日本一道在线 | 丁香婷婷社区 |