博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ruby 函数定义中使用 key:value 的作用
阅读量:4229 次
发布时间:2019-05-26

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

Ruby 中函数定义中参数使用 key=value 和 key:value 似乎是差不多的,但是其实还是有很大差异的,特别是有不止一个参数时:

[root@master ruby_learning]# cat test.rbdef test(host = HOST, port = PORT, index = 'jobs')  puts [host, port, index].inspectenddef test2(host = HOST, port = PORT, index: 'jobs')  puts [host, port, index].inspectendHOST='localhost'PORT='8200'test(index='nice')test(HOST, PORT, index='nice')putstest2(index:'nice')test2(HOST, PORT, index:'nice')[root@master ruby_learning]# ruby test.rb["nice", "8200", "jobs"]["localhost", "8200", "nice"]["localhost", "8200", "nice"]["localhost", "8200", "nice"]

 

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

你可能感兴趣的文章
UI层自动化测试框架(五):业务层和用例层
查看>>
Jenkins如何更改主目录
查看>>
TestNG实现用例运行失败自动截图和重跑
查看>>
ReportNG测试报告的定制修改
查看>>
模糊查询
查看>>
T-SQL中的聚合函数中的SUM()函数与AVG函数()
查看>>
T-SQL中的聚合函数(二)
查看>>
分组查询
查看>>
2021-06-04
查看>>
最长无重复子数组
查看>>
Dual-Primal Graph Convolutional Networks 对偶-原始图卷积神经网络
查看>>
GoGNN: Graph of Graphs Neural Network for Predicting Structured Entity Interactions
查看>>
Estimating Node Importance in Knowledge Graphs Using Graph Neural Networks
查看>>
DiffPool: Hierarchical Graph Representation Learning with Differentiable Pooling
查看>>
MuchGCN:Multi-Channel Graph Convolutional Networks
查看>>
kernel_size为1的卷积核与全连接层的关系
查看>>
STRATEGIES FOR PRE-TRAINING GRAPH NEURAL NETWORKS
查看>>
PAT_A 1010. Radix (25)
查看>>
PAT_A 1005. Spell It Right (20)
查看>>
PAT_A 1012. The Best Rank (25)
查看>>