Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用该函数dbstack来获取当前正在执行的函数的名称。dbstack返回一个结构,包含三个字段file:name和line。我只对name. 当我调用函数时,有什么方法可以只name返回字段dbstack,还是需要使用两行(以下)?
dbstack
file
name
line
thisFunction = dbstack; thisFunctionName = thisFunction.name;
您的解决方案是做您想做的最简单(并且可能是最好)的方法。
或者,您可以使用getfield
getfield
>> thisFunctionName = getfield( dbstack, 'name' )