change_prefix method

Result<IPAddress, String> change_prefix(
  1. Prefix prefix
)

Set a prefix number for the object

This is useful if you want to change the prefix to an object created with IPv4::parse_u32 or if the object was created using the classful mask.

ip = IPAddress("172.16.100.4")

puts ip /// 172.16.100.4/16

ip.prefix = 22

puts ip /// 172.16.100.4/22

Implementation

Result<IPAddress, String> change_prefix(Prefix prefix) {
  return Result.ok(this.from(this.host_address, prefix));
}