如何创建一个末尾有一个数字的对象,该数字在每次使用时都会递增?
我正在尝试创建一个变量,每次使用后都可以增加它。 $companyLevel os 是我需要增加的变量。
count = 20
# Variables (20)
while count > 0
$levelName = ""; 8.times{$levelName << (65 + rand(25)).chr}
$companyLevel = "CLev5"
browser2.button(:id, "addCompanyLevel").click
sleep 2
browser2.text_field(:id, $companyLevel).set $levelName
$companyLevel += 1
count -= 1
end
如何创建一个末尾有一个数字的变量,该数字在每次使用时都会递增?
谢谢。
I am trying to make a variable that I can increment each time after I use it.
The $companyLevel os the variable that I need to increment.
count = 20
# Variables (20)
while count > 0
$levelName = ""; 8.times{$levelName << (65 + rand(25)).chr}
$companyLevel = "CLev5"
browser2.button(:id, "addCompanyLevel").click
sleep 2
browser2.text_field(:id, $companyLevel).set $levelName
$companyLevel += 1
count -= 1
end
How do I create a variable that will have a number at the end that will increment each time it is used?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
既然你已经有了一个计数,为什么它需要是一个变量呢?为什么不直接进行简单的字符串连接来动态创建您想要的值,
除非您可能需要了解“数组”是什么?
我建议您购买并阅读《Everyday Scripting with Ruby》一书,这是学习 Ruby 语言基础知识并面向测试人员的好方法。
Since you already have a count, why does this need to be a variable? why not just do simple string concatenation to create the value you want on the fly
Unless you need to perhaps read up on what an 'array' is?
I'd suggest you purchase and read the book "Everyday Scripting with Ruby" it's a great way to lean the basics of the ruby language and geared towards testers.
这是通过创建一个具有递增属性的对象来实现的,而不是通过创建一个递增的变量来实现的。
This is achieved by creating an object with a property that increments not by creating a variable that increments.