h-Klok / StatsWithJuliaBook

https://statisticswithjulia.org/
MIT License
1.08k stars 279 forks source link

Listing 1.7, line 28, change of global variable lead to an implicit convention to local variable #2

Closed curow closed 5 years ago

curow commented 5 years ago

change the 28th line to

global state = sample(1:3,weights(P[state,:]))

will eliminate the UndefVarError: state not defined Error.

This error is due to Julia's Weird Convention for writing to a global variable. here is a more clear explain at Stack Overflow

h-Klok commented 5 years ago

Thank you for the find, the codes been fixed :)

VincentTam commented 5 years ago

@h-Klok Just a suggestion. Mentioning the issue (by typing #2) in your Git commit title/message would allow easier tracking.