I'm having fun learning nim by converting Advent of Code solutions I wrote in 
VBA.

In VBA you can shortcut long qualifiers using the With statement.
    
    
    Private Sub VmEquals()
        
        With s.Processor
            
            .Memory3 = IIf(.Memory1 = .Memory2, 1, 0)
            .ProgramCounter = .ProgramCounter + 4
        
        End With
    
    End Sub
    
    
    Run

In nim I eventually got to
    
    
    proc vmEquals(self: Computer) =
        var my = self.s.processor
        my.memory3 = if my.memory1 == my.memory2: 1 else: 0
        my.programCounter = my.programCounter + 4
    
    
    Run

My question is (having come up blank in searches), is there a more idiomatic 
way in nim that avoids having to declare an intermediate variable.

Reply via email to