"WiFi does not name a type" error for Arduino Yun

I figured it out it turns out that you have to put the WiFi.begin() under the void setup() otherwise you get this error