Unit is a Q# type with exactly one value, written (). As a return type, it indicates that an operation produces no return value and instead acts through effects such as changing qubit states or printing output. section 2.1.3
Q# quantum gates use Unit because their result is expressed by changing the state of their qubit arguments. Custom gates can also use Unit when they support adjoint and controlled specializations. section 2.3.4
Listing 2.2 Q# code to prepare a single-qubit state
import Std.Math.ArcTan2; #1
@EntryPoint() #2
operation SingleQubitDemo() : Unit { #3
use q = Qubit(); #4
let (alpha, beta) = (0.6, 0.8);
let theta = 2.0 * ArcTan2(beta, alpha); #5
Ry(theta, q); #6
Reset(q); #7
}
A minimal Q# operation declares Unit as its return type, prepares a qubit with Ry, and resets the qubit before completion. section 2.1.3
Inspecting a Unit result
Running a Unit-returning operation produces the output Result: "()". The empty tuple is successful completion, not information about the quantum state; state inspection requires a separate diagnostic such as DumpMachine. section 2.1.3 section 2.3.4






