博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zemax微透镜阵列示例_阵列反向! Ruby中的示例方法
阅读量:2530 次
发布时间:2019-05-11

本文共 3607 字,大约阅读时间需要 12 分钟。

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 declarationLang = ["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: KotlinArray 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 declarationTable = [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: 20Array 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实例中内容的实际排列。

翻译自:

zemax微透镜阵列示例

转载地址:http://orxzd.baihongyu.com/

你可能感兴趣的文章
Centos 7 Mysql 最大连接数超了问题解决
查看>>
thymeleaf 自定义标签
查看>>
关于WordCount的作业
查看>>
C6748和音频ADC连接时候的TDM以及I2S格式问题
查看>>
UIView的layoutSubviews,initWithFrame,initWithCoder方法
查看>>
STM32+IAP方案 实现网络升级应用固件
查看>>
用74HC165读8个按键状态
查看>>
jpg转bmp(使用libjpeg)
查看>>
linear-gradient常用实现效果
查看>>
sql语言的一大类 DML 数据的操纵语言
查看>>
VMware黑屏解决方法
查看>>
JS中各种跳转解析
查看>>
JAVA 基础 / 第八课:面向对象 / JAVA类的方法与实例方法
查看>>
Ecust OJ
查看>>
P3384 【模板】树链剖分
查看>>
Thrift源码分析(二)-- 协议和编解码
查看>>
考勤系统之计算工作小时数
查看>>
4.1 分解条件式
查看>>
Equivalent Strings
查看>>
flume handler
查看>>