I'm attempting to loop through an array of addresses to check if a certain address (parameter) is in the array.
//SPDX-License-Identifier: MIT
pragma solidity 0.8.14;
contract RSVP {
address public Host;
address[] public rsvpAddresses;
constructor() {
Host = msg.sender;
}
/// Only the Host can call this function
error OnlyHost();
modifier onlyHost() {
if (msg.sender != Host) {
revert OnlyHost();
}
_;
}
function rsvp() public payable {
require(msg.value == 1 ether);
rsvpAddresses.push(msg.sender);
}
function eventStartCheckIn(address payable guest) public onlyHost {
for (uint i = 0; i < rsvpAddresses.length; i++) {
if (guest = rsvpAddresses[i])
guest.transfer(1 ether);
}
}
}
The error is on line 31 (with the for loop and if statement). "Type address is not implicitly convertible to expected type address payable." & "Type address payable is not implicitly convertible to expected type bool." I feel like these errors occur because the if statement is comparing an address (guest) to an array position but I can't figure out how to fix this.