You can make the parameter in the function be bar
    
    
    type
       MyObj = object
         prop: string
    
    proc doitWithObj(myObj: var MyObj) =
      myObj.prop = "hallo"
    
    var x: MyObj
    
    x = MyObj()
    x.prop = "bon jour"
    echo x.prop
    
    doitWithObj((x)
    echo x.prop
    # but it means it only works with var variables
    let y = MyObj()
    doitWithObj(y) # compile error
    
    
    Run

Reply via email to