Skip to content

Write-Output vs. Return vs. $Output #46

@Jaykul

Description

@Jaykul

There is currently a recommendation in Function and Structure to not use "return" but it says to "just put the variable on a line by itself" ...

I wonder if that's the majority opinion?

Assuming this is the last line of my function, what's better:

$output = $temp + (Get-Thing $temp)
return $output
$output = $temp + (Get-Thing $temp)
$output
$output = $temp + (Get-Thing $temp)
Write-Output $output

I won't go into piping output to Write-Output ;-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions