wren icon indicating copy to clipboard operation
wren copied to clipboard

Whitespace bugs?

Open andydude opened this issue 11 months ago • 4 comments

I only started using Wren yesterday, so I might have missed something in the docs. I was experimenting with OOP in Wren and I couldn't understand why all of the properties were always null! So I made a simple test case, and managed to figure out that it was the white-space that was causing the issue. I boiled it down to this code:

var b = Box.new(2)
System.print(b.x)

When this code is run with Box1, it works as expected, it prints 2. When this code is run with Box2, then it prints null. What exactly is happening here? Shouldn't Box2 work exactly the same as Box1?

Box 1

class Box1 {
    x { _x }
    x=(value) { _x = value }
    construct new(x) { _x = x }
}

Box 2

class Box2 {
    x { 
        _x 
    }
    
    x=(value) { 
        _x = value 
    }
    
    construct new(x) {
        _x = x
    }
}

andydude avatar Jul 28 '23 21:07 andydude