你能组合方法并捕获输出吗?
Can you combine methods and capture the output?
我有一个看起来像这样的方法:
proc getJobinfo {question} {
puts -nonewline "$question: "
flush stdout
gets stdin answer
# Can you combine totitle and trim into one line?
set titledanswer [string totitle $answer]
return $titledanswer
}
我想在一行中调用 trim
和 totitle
,可以吗?
例如,在Python
中:
company_name : str = userInput.trim().title()
是的,你可以:
set titledanswer [string trim [string totitle $answer]]
我有一个看起来像这样的方法:
proc getJobinfo {question} {
puts -nonewline "$question: "
flush stdout
gets stdin answer
# Can you combine totitle and trim into one line?
set titledanswer [string totitle $answer]
return $titledanswer
}
我想在一行中调用 trim
和 totitle
,可以吗?
例如,在Python
中:
company_name : str = userInput.trim().title()
是的,你可以:
set titledanswer [string trim [string totitle $answer]]