I am studying because I want to publish my results through Google Earth Engine. Regarding the usage of if / else and ee.Algorithms.If()
, I don't understand why both true case and false case work.
As per Code, I want to check if the value selected from ui.Select
s
corresponds to List v
.
var s = ui.Select({
items: [
{label: 'A', value: 'A'},
{label: 'B', value: 'B'},
]
});
var b = ui.Button('Go!');
b.onClick(b_function);
//var v = ee.List(['A', 'B', 'C']);
var v = ee.List(['C']);
function b_function(){
ee.Algorithms.If(v.contains(s.getValue()), print('True!'), ui.root.add(ui.Label({value:'False!'})));
}
ui.root.add(s);
ui.root.add(b);
Is this possible even with a general if / else statement in google earth engine?
function b_function(){
If(v.contains(s.getValue()){print('True!')}
else(ui.root.add(ui.Label({'False!'});
}