如何在Julia中恢复默认常量值

时间:2014-07-06 11:59:41

标签: variables julia

根据docs,在朱莉娅,我可以做以下事情:

julia> pi
π = 3.1415926535897...

julia> pi = 3
Warning: imported binding for pi overwritten in module Main
3

我如何才能将pi恢复到适当的价值?

1 个答案:

答案 0 :(得分:7)

您可以访问Base.pi下的原始文件:

julia> pi
π = 3.1415926535897...

julia> pi = 3
Warning: imported binding for pi overwritten in module Main
3

julia> Base.pi
π = 3.1415926535897...

julia> pi = Base.pi;

julia> pi
π = 3.1415926535897...

julia> cos(pi)
-1.0