如何从函数或范围中获取变量? [英] How do I get variables from a function or scope ?

查看:62
本文介绍了如何从函数或范围中获取变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Code Project Peeps,

我想从函数或范围中获取所有简单变量。我怎么能这样做,





下面的代码只是 pascal 代码









例如不会叫,但你会理解





Hello Code Project Peeps,
I want to get all simple variables from a function or scope. How can i do this,


The code below is just pascal code




For example "Not Woking but you will understand"


Public Function TestFunction()
    Dim varone,vartwo
    varone  = "1"
    vartwo  = "2"
End Function

Public Function dump()
    for each (var item in TestFunction())
        console.write(item.name + ":" +item.var)
End Function













Console Output should be :
varone:1
vartwo:2

推荐答案

您无法查看函数范围的变量,因为它是私有的。隐藏实现细节是功能和方法的预期思想。你可以将writelines放在TestFunction中,因为变量仍在范围内。



祝你好运!
You can't look into the variables of a function scope because it is private. It is the intended idea of functions and methods, to hide implementation details. You can place the writelines in the TestFunction because there the variables are still into scope.

Good luck!


这篇关于如何从函数或范围中获取变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆