I haven't done EE for quite a long time. I need to implement some MUX, so I started with a two-way MUX.  But I don't understand how to make the decision:

![enter image description here][1]


[Wiki- Multiplexer][2]


  [1]: https://i.sstatic.net/uU5rv.png
  [2]: http://en.wikipedia.org/wiki/Multiplexer
A truth table will show that 

> This truth table shows that when  **S=0** then 
> **Z=A** but when **S=1** then  **Z=B**.

I don't get the logic here. The boolean expression is **Z = (A and S') or (B and S)**

----

Let S = 0, then each sub expression will become

                z1

A = 0,  S' = 1   =>   0

A = 1,  S' = 1   =>  1


                z2

B = 0,  S = 0    => 0

B = 1,  S = 0    => 0


Can someone please explain to me how do we reach that conclusion? Thank you very much!