Call again or store in variable?
Posted: Thu Oct 18, 2018 3:05 pm
Just a quick theory question. If i want to for example print the ip with WiFi.localIP() to multiple outputs (Serial, LCD...). What is better, calling WiFi.localP() multiple times or store it in a (string?) variable and print said variable? I'm not sure what exactly happens when i just call that vs. storing a variable.
Why I'm asking this possibly weird noob question: i learned that the IPAddress isn't - as i thought - a simple string, but a a whole class with its own header IPAddress.h. I then was wondering if storing (and possibly converting it into a string) was necessary at all if i can just for example Serial.print(WiFi.localIP()[3]) to get just the last octet printed in the console and the whole address on a LCD with WiFi.localIP().
Why I'm asking this possibly weird noob question: i learned that the IPAddress isn't - as i thought - a simple string, but a a whole class with its own header IPAddress.h. I then was wondering if storing (and possibly converting it into a string) was necessary at all if i can just for example Serial.print(WiFi.localIP()[3]) to get just the last octet printed in the console and the whole address on a LCD with WiFi.localIP().