Skip to content

Commit

Permalink
✨ Adds OFS to AboutStrings (#204)
Browse files Browse the repository at this point in the history
* Adds a short section about OFS
  • Loading branch information
indented-automation authored and vexx32 committed Jun 16, 2019
1 parent 3320e2c commit 21f8e42
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions PSKoans/Koans/Foundations/AboutStrings.Koans.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,35 @@ All things that are not 'evaluated' are "recognised" as characters.
'__' | Should -Be $AllYourQuotes
}
}

Context 'Arrays and Strings' {
<#
An array can be inserted into a string in PowerShell.
#>
It 'joins using a space by default' {
$array = @(
'Hello'
'world'
)
'____ ____' | Should -Be "$array"
}

It 'can be joined with a different string by setting the ofs variable' {
<#
The $OFS variable, short for output field separator, defines the separator used
to join an array when it is included in a string.
By default, the OFS variable is unset, and a single space is used as the separator.
#>

$ofs = '... '
$array = @(
'Hello'
'world'
)
'____' | Should -Be "$array"

Remove-Variable ofs
}
}
}

0 comments on commit 21f8e42

Please sign in to comment.