从有选项的值通常是一个从零开始的索引或一个基于索引? [英] Have values from options usually a zero based index or a one based index?
本文介绍了从有选项的值通常是一个从零开始的索引或一个基于索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
随着'大胆'选项,我可以选择哪些应印大胆的元素。
我应该使用'0'或'1'的第一个元素(一个)?
my_print([一,二,三化] {大胆=> 1});
或
my_print([一,二,三化] {大胆=> 0});
解决方案
在Perl指标与 0
开始,所以我建议你实现这种方式了。
With the 'bold' option I can choose an element which should be printed bold. Should I use '0' or '1' for the first element (one)?
my_print( [ 'one', 'two', 'three' ], { bold => 1 } );
or
my_print( [ 'one', 'two', 'three' ], { bold => 0 } );
解决方案
Indexes in Perl starts at 0
so I suggest you implement it that way too.
这篇关于从有选项的值通常是一个从零开始的索引或一个基于索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文