zemax微透鏡陣列示例_陣列反向! Ruby中的示例方法

zemax微透鏡陣列示例

陣列反向! 方法 (Array reverse! Method)

In this article, we will study about Array.reverse! method. You all must be thinking the method must be doing something related to reversing certain elements as we have done in the case of Array.reverse! method. 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.reverse! 方法 。 大家都必須認為該方法必須像在Array.reverse情況下所做的那樣與反轉某些元素有關! 方法。 它并不像看起來那么簡單。 好吧,我們將在其余內容中解決這個問題。 我們將嘗試借助語法并演示程序代碼來理解它。

Method description:

方法說明:

This method is a public instance method and defined for the Array class in Ruby's library. This method works in a way that reverses the content or objects present inside the Array instances. It traverses the Array elements in the way that the last element is considered to be first and the first object is considered to be the last element of the object of Array instance. Array.reverse is a destructive method where the changes created by this method would impact the actual order of the Self Array instance and these changes are permanent.

該方法是一個公共實例方法,為Ruby庫中的Array類定義。 此方法的工作方式是反轉Array實例中存在的內容或對象。 它以以下方式遍歷Array元素:將最后一個元素視為第一個元素,將第一個對象視為Array實例對象的最后一個元素。 Array.reverse是一種破壞性方法,其中此方法創建的更改將影響Self Array實例的實際順序,并且這些更改是永久的。

Syntax:

句法:

    Array_instance.reverse! -> new_array

Argument(s) required:

所需參數:

This method does not require any argument. Reversing the Array instance does not require anything rather than the Array instance itself.

此方法不需要任何參數。 反轉Array實例不需要什么,只需要Array實例本身即可。

Example 1:

范例1:

=begin
Ruby program to demonstrate reverse! method
=end
# array declaration
Lang = ["C++","Java","Python","Html","Javascript","php","Ruby","Kotlin"]
puts "Array reverse! implementation."
print Lang.reverse!
puts ""
puts "The first element of the Array is: #{Lang[0]}"
puts "Array elements are:"
print Lang

Output

輸出量

Array reverse! implementation.
["Kotlin", "Ruby", "php", "Javascript", "Html", "Python", "Java", "C++"]
The first element of the Array is: Kotlin
Array elements are:
["Kotlin", "Ruby", "php", "Javascript", "Html", "Python", "Java", "C++"]

Explanation:

說明:

In the above code, you can observe that we are reversing the contents of Array class instance with the help of Array.reverse! method. You can observe that after reversing the contents, the first element is "Kotlin" because this method is a destructive method and creates changes in the actual arrangements of contents in Array instance.

在上面的代碼中,您可以觀察到借助Array.reverse ,我們正在反轉Array類實例的內容 方法 。 您可以觀察到,在反轉內容之后,第一個元素是“ Kotlin”,因為此方法是一種破壞性方法,會在Array實例中實際更改內容的排列方式。

Example 2:

范例2:

=begin
Ruby program to demonstrate reverse! method
=end
# array declaration
Table = [2,4,6,8,10,12,14,16,18,20]
puts "Array reverse! implementation"
print Table.reverse!
puts ""
puts "The first element of the Array is: #{Table.first}"
puts "Array elements are:"
print Table

Output

輸出量

Array reverse! implementation
[20, 18, 16, 14, 12, 10, 8, 6, 4, 2]
The first element of the Array is: 20
Array elements are:
[20, 18, 16, 14, 12, 10, 8, 6, 4, 2]

Explanation:

說明:

In the above code, you can observe that this method works on Integer Array as well and we are reversing the contents of Array class instance with the help of Array.reverse! method. You can observe that after reversing the contents, the first element is 20 because this method is destructive and creates changes in the actual arrangements of contents in the Array instance.

在上面的代碼中,您可以觀察到該方法也適用于Integer Array,并且借助于Array.reverse ,我們正在反轉Array類實例的內容 方法 。 您可以觀察到,在反轉內容之后,第一個元素為20,因為此方法具有破壞性,并會更改Array實例中內容的實際排列。

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

zemax微透鏡陣列示例

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/378692.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/378692.shtml
英文地址,請注明出處:http://en.pswp.cn/news/378692.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Opencv實戰【1】人臉檢測并對ROI區域進行部分處理(變身喬碧蘿!!!)

步驟: 1、利用Opencv自帶的分類器檢測人臉 預備知識:Haar特征分類器 Haar特征分類器就是一個XML文件,該文件中會描述人體各個部位的Haar特征值。包括人臉、眼睛、嘴唇等等。 Haar特征分類器存放地址: (找自己的安裝…

【黑馬甄選離線數倉day10_會員主題域開發_DWS和ADS層】

day10_會員主題域開發 會員主題_DWS和ADS層 DWS層開發 門店會員分類天表: 維度指標: 指標:新增注冊會員數、累計注冊會員數、新增消費會員數、累計消費會員數、新增復購會員數、累計復購會員數、活躍會員數、沉睡會員數、會員消費金額 維度: 時間維度&#xff08…

iPad和iPhone的app圖標尺寸、用途、設置方法

下面是在iPhone專用程序、iPad專用程序和通用程序中使用圖標文件的指導,由譯言網翻譯自蘋果官方文檔。原文 http://article.yeeyan.org/view/395/100567 注意:圖標是你的程序包所必需的組成部分。如果你沒有提供程 序所需的各種尺寸的圖標,系…

18-傅里葉變化

以時間為參照就是時域分析,當然時間是動態變化的 而傅里葉變換是以頻域為基準的,不用關心動態變化,只關心做了多少次而已,次數,頻率 傅里葉說過,任何一個周期函數都可以用正弦函數堆疊起來形成。強吧&#…

java中訪問修飾符_Java中的非訪問修飾符是什么?

java中訪問修飾符Java非訪問修飾符 (Java non access modifiers) We have 7 non-access modifiers in Java. The name of these non-access modifiers are given below, Java中有7個非訪問修飾符 。 這些非訪問修飾符的名稱如下所示: native 本機 synchronized 已同…

mui實現分享功能_MUI 分享功能(微信、QQ 、朋友圈)

配置文件:manifest.jsonplus ->plugins 下邊"share": {/*配置應用使用分享功能,參考http://ask.dcloud.net.cn/article/27*/"qq": {"appid": "",/*騰訊QQ開放平臺申請應用的AppID值*/"description"…

Java 注解學習筆記

轉自:http://wanqiufeng.blog.51cto.com/409430/458883 一、什么是java注解 注解,顧名思義,注解,就是對某一事物進行添加注釋說明,會存放一些信息,這些信息可能對以后某個時段來說是很有用處的。 Java注解又叫java標注…

Prime Palindromes

博客園速度非常不穩定,可能要考慮換地方了。雖然我非常喜歡博客園的模板和氣氛。 這個題早就知道是怎么做的了。先求出回文數在再判斷是不是素數。關鍵是不知道區間,那就把所有的全部求出來。雖然可能會超時,但是如果使用點技巧的話還是沒問題…

Opencv——DFT變換(實現兩個Mat的卷積以及顯示Mat的頻域圖像)

DFT原理:(單變量離散傅里葉變換) 數學基礎: 任何一個函數都可以轉換成無數個正弦和余弦函數的和的形式。 通常觀察傅里葉變換后的頻域函數可以獲得兩個重要的信息:幅頻曲線和相頻曲線。 在數字圖像處理中的作用&#…

python方法items_Python字典items()方法與示例

python方法items字典items()方法 (Dictionary items() Method) items() method is used to get the all items as a view object, the view object represents the key-value pair of the dictionary. items()方法用于獲取所有項目作為視圖對象,該視圖對象表示字典的…

基于(Python下的OpenCV)圖像處理的噴墨墨滴形狀規范檢測

通過圖像處理,分析數碼印花的噴頭所噴出來的墨滴形狀,與標準墨滴形狀對比分析,來判斷墨水及其噴頭設備的狀態,由兩部分構成 PS:獲取墨滴形狀照片和標準墨滴形狀照片都是手繪的,將就的看吧,主要…

const_iterator,const 迭代器

const 迭代器:是迭代器產量,該迭代器的值不能被修改,且需要初始化,初始化之后不能指向其他元素。const_iterator:當我們對const_iterator類型解引用時,返回一個const值,所以只能讀,不能寫。它是一種迭代器…

臨時禁止令:諾西購摩托羅拉面臨流產窘境?

近日,美國伊利諾伊州北區法院就中國華為起訴摩托羅拉公司和諾西一案作出初步裁決,禁止摩托羅拉解決方案公司(Motorola Solutions)向諾西披露華為的機密資料。此判決一出,各方評論紛沓而來。筆者認為,從諾西12以美元并購摩托羅拉部…

mysql replace into 語法_mysql Replace into與Insert update

Replace intoreplace into 跟 insert 功能類似,不同點在于:replace into 首先嘗試插入數據到表中,1. 如果發現表中已經有此行數據(根據主鍵或者唯一索引判斷)則先刪除此行數據,然后插入新的數據。2. 否則,直接插入新數…

微機原理——指令系統——傳送類指令(MOV、LEA、LDS、LES、LAHF、SAHF、XCHG、XLAT、PUSH、POP、PUSHF、POPF)

博主聯系方式: QQ:1540984562 QQ交流群:892023501 群里會有往屆的smarters和電賽選手,群里也會不時分享一些有用的資料,有問題可以在群里多問問。 【沒事兒可以到我主頁看看】https://blog.csdn.net/qq_42604176 傳送類指令1&…

lastindexof方法_Java Vector lastIndexOf()方法與示例

lastindexof方法向量類別的lastIndexOf()方法 (Vector Class lastIndexOf() method) Syntax: 句法: public int lastIndexOf (Object ob);public int lastIndexOf (Object ob, int indices);lastIndexOf() method is available in java.util package. lastIndexOf(…

李開復:微博的價值在哪里

導讀:微博可以改變社會現象,可以傳播信息,可以幫助你成長,可以發出你的聲音。它讓我們能夠人人成為記者,讓每一個轉發的人都變成了一個編輯 很多人問微博是搶了誰的生意,開心網還是人人網?其實它…

mysql 任務計劃 /etc/cron.d_Linux /etc/cron.d增加定時任務

一般情況下我們添加計劃任務時,都是直接修改/etc/crontab。但是,不建議這樣做,/etc/cron.d目錄就是為了分項目設置計劃任務而創建的。例如,增加一項定時的備份任務,我們可以這樣處理:在/etc/cron.d目錄下新…

19-Harris角點檢測

角點檢測顧名思義,就是對類似頂點的檢測,與邊緣有所區別 邊緣可能在某一方向上變化不是特別明顯,但角點在任何方向上變換都很明顯 cv2.cornerHarris(img,blockSize,ksize,k) cv2.cornerHarris(gray,2,3,0.04) 參數一:img&#xff…

微機原理——指令系統——算數運算指令(ADD、ADC、SUB、SBB、INC、DEC、NEG、CMP、MUL、IMUL、DIV、IDIV、CBW、CWD、BCD調整)

博主聯系方式: QQ:1540984562 QQ交流群:892023501 群里會有往屆的smarters和電賽選手,群里也會不時分享一些有用的資料,有問題可以在群里多問問。 算數運算指令1、加減法指令ADD、ADC 、SUB 、SBB 和增量減量指令INC、DEC、NEGADD…