首页 > 其他 > 详细

区分args(Argument)【引数】与 parm(Parameter)【参数】

时间:2020-02-27 16:05:47      阅读:104      评论:0      收藏:0      [点我收藏+]

首先引用一段英文介绍

An argument is an expression used when calling the method.
A parameter is the variable which is part of the method’s signature (method declaration).

--选自 stackoverflow

看过的一些文章和书籍较少对这两个名称做限定,一般都翻译为或者读作 ‘参数’,但是在使用和写文档时候还是要加以区分才让人好理解。

台湾版的翻译中,翻译 args为引数,param为参数。光听名称也是不好理解,我下面写一个例子来清晰表示。

  1. /** 
  2.   * Description: Args and Param Comparision 
  3.   * author: J.K.alex 
  4.   * Date: Created in 13:45 2020/2/27 
  5.   */  
  6. class Student(age: Int, name: String) {  
  7.   /** 这里的name 、 age 是args(arguments) */  
  8.   def this(name: String, age: Int) = {  
  9.     this(age, name)  
  10.     println(s"This is $name ,his/her age is $age")  
  11.   }  
  12.   
  13.   println(s"Age is $age ,his/her name is $name")  
  14. }  
  15.   
  16. object Demo {  
  17.   def main(args: Array[String]): Unit = {  
  18.     /** 这里传入的 25 \ alex 是 param(parameters) */   
  19.     val student = new Student(25, "alex")  
  20.   }  
  21. }  

区分args(Argument)【引数】与 parm(Parameter)【参数】

原文:https://www.cnblogs.com/samad/p/12372084.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!