1 tcl
lsearch的奇怪问题没有表现.我可能做了一些愚蠢的事.任何想法/帮助将非常感谢!
set mylist {}
lappend mylist a
lappend mylist b
lappend mylist c
set test [lsearch -exact mylist b]
puts "This doesn't work, result should be 1 = $test"
set test2 [lsearch {a b c d e} c]
puts "This works, result should be 2 = $test2"
Run Code Online (Sandbox Code Playgroud)
您正在搜索包含单个元素的列表:
{mylist}
Run Code Online (Sandbox Code Playgroud)
您需要传递变量mylist:
lsearch -exact $mylist b
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
334 次 |
| 最近记录: |