Skip to content

Commit c2ed332

Browse files
author
James Brundage
committed
feat: Turtle method chaining ( Fixes #22 )
Returning $this
1 parent c9b7834 commit c2ed332

File tree

6 files changed

+9
-4
lines changed

6 files changed

+9
-4
lines changed

Types/Turtle/Clear.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
$this.Position = 0, 0
22
$this.Heading = 0
3-
$this.Steps = @()
3+
$this.Steps = @()
4+
return $this

Types/Turtle/Forward.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ $x = $Distance * [math]::round([math]::cos($this.Heading * [Math]::PI / 180),15)
77
$y = $Distance * [math]::round([math]::sin($this.Heading * [Math]::PI / 180),15)
88
$this.Position = $x, $y
99
$this.Steps += "l $x $y"
10+
return $this

Types/Turtle/L.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ foreach ($character in $finalState.ToCharArray()) {
4444
}
4545
}
4646
}
47-
return
47+
return $this

Types/Turtle/Rotate.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
Rotates the turtle by the specified angle.
66
#>
77
param([double]$Angle = 90)
8-
$this.Heading += $Angle
8+
$this.Heading += $Angle
9+
return $this

Types/Turtle/SierpinskiTriangle.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ $this.L('F-G-G', [Ordered]@{
1111
'-' = { $this.Rotate($Angle * -1) }
1212
'[FG]' = { $this.Forward($Size) }
1313
})
14+
return $this

Types/Turtle/Square.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ param([double]$Size = 50)
22
foreach ($n in 1..4) {
33
$this.Forward($Size)
44
$this.Rotate(90)
5-
}
5+
}
6+
return $this

0 commit comments

Comments
 (0)