npx i create-react-app
npx create-react-app my-app
function foo(currentNumber){
console.log(currentNumber);
currentNumber++;
}
setInterval(foo, 1000, 5);
Здесь, наверное, понятно, почему будет каждый раз 5 ?foo(5); // выведет 5
foo(5); // выведет 5
foo(5); // выведет 5
Внутренняя переменная функции изначально 5, выводит 5 и становится 10. Функция завершила работу, про переменную все забыли. let interval = setInterval(function(obj){
console.log(obj.currentNumber);
obj.currentNumber++;
}, 1000, {currentNumber:5});
func filter(_ isIncluded: (Self.Element) throws -> Bool) rethrows -> [Self.Element]
words.filter { word in return word.count >= 3 }
func contains(_ element: Character) -> Bool
def deleteResult(request, item_id):
if request.user.is_authenticated:
try:
item = Results.objects.get(item_id=item_id)
item.delete()
return HttpResponseRedirect("/results")
except Items.DoesNotExist:
return HttpResponseNotFound("<h2>Result not found</h2>")
return HttpResponseRedirect('/register')
-----------------------------------com.example.Clouds.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Clouds {
@SerializedName("all")
@Expose
public int all;
}
-----------------------------------com.example.Coord.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Coord {
@SerializedName("lon")
@Expose
public double lon;
@SerializedName("lat")
@Expose
public double lat;
}
-----------------------------------com.example.Example.java-----------------------------------
package com.example;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Example {
@SerializedName("coord")
@Expose
public Coord coord;
@SerializedName("weather")
@Expose
public List<Weather> weather = null;
@SerializedName("base")
@Expose
public String base;
@SerializedName("main")
@Expose
public Main main;
@SerializedName("visibility")
@Expose
public int visibility;
@SerializedName("wind")
@Expose
public Wind wind;
@SerializedName("clouds")
@Expose
public Clouds clouds;
@SerializedName("dt")
@Expose
public int dt;
@SerializedName("sys")
@Expose
public Sys sys;
@SerializedName("timezone")
@Expose
public int timezone;
@SerializedName("id")
@Expose
public int id;
@SerializedName("name")
@Expose
public String name;
@SerializedName("cod")
@Expose
public int cod;
}
-----------------------------------com.example.Main.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Main {
@SerializedName("temp")
@Expose
public double temp;
@SerializedName("feels_like")
@Expose
public double feelsLike;
@SerializedName("temp_min")
@Expose
public double tempMin;
@SerializedName("temp_max")
@Expose
public double tempMax;
@SerializedName("pressure")
@Expose
public int pressure;
@SerializedName("humidity")
@Expose
public int humidity;
}
-----------------------------------com.example.Sys.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Sys {
@SerializedName("type")
@Expose
public int type;
@SerializedName("id")
@Expose
public int id;
@SerializedName("country")
@Expose
public String country;
@SerializedName("sunrise")
@Expose
public int sunrise;
@SerializedName("sunset")
@Expose
public int sunset;
}
-----------------------------------com.example.Weather.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Weather {
@SerializedName("id")
@Expose
public int id;
@SerializedName("main")
@Expose
public String main;
@SerializedName("description")
@Expose
public String description;
@SerializedName("icon")
@Expose
public String icon;
}
-----------------------------------com.example.Wind.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Wind {
@SerializedName("speed")
@Expose
public int speed;
@SerializedName("deg")
@Expose
public int deg;
}