I think the self is bound at the block creation
To be confirm, Ben On Jan 25, 2012, at 9:54 PM, Garret Raziel wrote: > Hi, I have one begginer question. It is may be simple, but it very baffles me. > > I am reading Pharo by Example (great book btw, thanks!). I'm in chapter two > where I'm creating Lights Out game. There is this simple code > http://pastebin.com/eQregZ35. What baffles me is line 10. I assign "Block of > code" to mouseAction variable of LOCell. In this Block, there is "self", that > obviously refers to LOGame object in that time. But when is this Block > actualy EVALUATED (when I click on Cell), "self" should be reffering to > LOCell object, isn't it? If I inspect one LOCell, inspector shows that it has > instance variable "mouseAction", which is BlockClosure, that looks like > "[self toggleNeighboursOfCellAt: i at: j]". If "LOCell" is the "owner" of > this block and also it is the one that evaluates it, shouldn't "self" refer > to LOCell object? How BlockClosure desides where "self" actually points? > > Thanks for explanation. > Jan
