Hi I'm trying to modify an object from the outside through another object.

The reason for this is that I'd like a tween object to tween the variables of a 
target object. How would I achieve this?

Example code:
    
    
    type Entity = ref object
      rotation: int
    
    type Tweener = ref object
      target: var int
    
    proc applyTween(t: Tweener, newValue: int) =
      t.target = newValue
    
    var e = new Entity
    var t = Tweener(target: e.rotation) # Error: invalid type: 'var int' in 
this context: 'Tweener' for var
    
    t.applyTween(20)
    echo "Entity(" & $e.rotation & ")" # Should output "Entity(20)"
    
    
    Run

Playground link: <https://play.nim-lang.org/#ix=4MzG>

I was thinking of using the `var` keyword, as my understanding of it is that it 
is similar to a pointer. However I am unable to get it working. 

Reply via email to