A heat exchanger comprising: a first heat exchanger unit including a plurality of first refrigerant flow paths, a first connection port in fluid communication with the plurality of first refrigerant flow paths, and a second connection port provided on the side opposite to the first connection port and configured to be in fluid communication with the plurality of first refrigerant flow paths; a second heat exchanger unit including at least one second refrigerant flow path, a third connection port in fluid communication with the second refrigerant flow path, and a fourth connection port provided on the side opposite to the third connection port and configured to be in fluid communication with the second refrigerant flow path; and a switching valve including a first inlet/outlet port connected to the first connection port, a second inlet/outlet port connected to the third connection port, a third inlet/outlet port connected to the second connection port, a fourth inlet/outlet port connected to the fourth connection port, a first valve flow path configured to fluidly communicate the first inlet/outlet port with the second inlet/outlet port, a second valve flow path configured to fluidly communicate the second inlet/outlet port with the third inlet/outlet port, and a third valve flow path configured to fluidly communicate the third inlet/outlet port with the fourth inlet/outlet port, the number of the plurality of first refrigerant flow paths in the first heat exchanger unit being configured to be greater than the number of the at least one second refrigerant flow path in the second heat exchanger unit, and the switching valve being configured to close the first valve flow path and the third valve flow path but open the second valve flow path or to open the first valve flow path and the third valve flow path but close the second valve flow path. a first heat exchanger unit including a plurality of first refrigerant flow paths, a first connection port in fluid communication with the plurality of first refrigerant flow paths, and a second connection port provided on the side opposite to the first connection port and configured to be in fluid communication with the plurality of first refrigerant flow paths; a plurality of first refrigerant flow paths, a first connection port in fluid communication with the plurality of first refrigerant flow paths, and a second connection port provided on the side opposite to the first connection port and configured to be in fluid communication with the plurality of first refrigerant flow paths; a second heat exchanger unit including at least one second refrigerant flow path, a third connection port in fluid communication with the second refrigerant flow path, and a fourth connection port provided on the side opposite to the third connection port and configured to be in fluid communication with the second refrigerant flow path; and at least one second refrigerant flow path, a third connection port in fluid communication with the second refrigerant flow path, and a fourth connection port provided on the side opposite to the third connection port and configured to be in fluid communication with the second refrigerant flow path; and a switching valve including a first inlet/outlet port connected to the first connection port, a second inlet/outlet port connected to the third connection port, a third inlet/outlet port connected to the second connection port, a fourth inlet/outlet port connected to the fourth connection port, a first valve flow path configured to fluidly communicate the first inlet/outlet port with the second inlet/outlet port, a second valve flow path configured to fluidly communicate the second inlet/outlet port with the third inlet/outlet port, and a third valve flow path configured to fluidly communicate the third inlet/outlet port with the fourth inlet/outlet port, a first inlet/outlet port connected to the first connection port, a second inlet/outlet port connected to the third connection port, a third inlet/outlet port connected to the second connection port, a fourth inlet/outlet port connected to the fourth connection port, a first valve flow path configured to fluidly communicate the first inlet/outlet port with the second inlet/outlet port, a second valve flow path configured to fluidly communicate the second inlet/outlet port with the third inlet/outlet port, and a third valve flow path configured to fluidly communicate the third inlet/outlet port with the fourth inlet/outlet port, the number of the plurality of first refrigerant flow paths in the first heat exchanger unit being configured to be greater than the number of the at least one second refrigerant flow path in the second heat exchanger unit, and the switching valve being configured to close the first valve flow path and the third valve flow path but open the second valve flow path or to open the first valve flow path and the third valve flow path but close the second valve flow path.