
Go Learning Notes - Part 3: If, Else If, Else Statements
Today I improved my Go Conference Booking App by adding conditional logic and better loop control. Instead of allowing any booking, I now validate user input using if , else if , and else statements. Here’s what I learned: Boolean Expressions in Go In Go, conditions inside if statements must evaluate to a boolean ( true or false ). Example from my program: if userTickets < remainingTickets This expression returns: true - booking is allowed false - booking is denied Comparison operators I used: < less than == equal to > greater than If Statement (Main Booking Logic) if userTickets < remainingTickets { remainingTickets = remainingTickets - userTickets bookings = append(bookings, fName+" "+lName) } What This Does: Checks if enough tickets are available Deducts tickets Saves the booking Displays confirmation This made my app smarter and prevented overbooking. Else If Statement else if userTickets == remainingTickets { // do something else } This condition handles the case where: The user b
Continue reading on Dev.to
Opens in a new tab

