This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.post('/customers/:customerId/orders/', (req, res) => { | |
if (req.body.items.length === 0) { | |
res.status(400).end() | |
} else { | |
MongoClient.connect(url, function (err, client) { | |
if (err) { | |
console.error(err) | |
} | |
const db = client.db(dbName) | |
const collection = db.collection('orders') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const updateStatus = (order, newStatus) => { | |
if (order.status === undefined) { | |
order.status = 'ORDERED' | |
} | |
//... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Model = Model | |
{ name :: String | |
, gender :: String | |
, loading :: Bool | |
, homeworld :: String | |
} deriving (Show) | |
data PersonResponse = PersonResponse | |
{ personName :: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withFunction = { | |
myOwnProp: 42, | |
myOwnFunc: function () { | |
return this.myOwnProp | |
} | |
} | |
const withArrow = { | |
myOwnProp: 42, | |
myOwnFunc: () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
class Fair { | |
private final int quantity; | |
Fair(int quantity) { | |
this.quantity = quantity; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.stream.Stream; | |
public class ReduceSum { | |
public static void main(String args[]) { | |
int sum = Stream.of(1, 2, 3, 4, 5) | |
.reduce(0, (acc, item) -> acc + item); | |
System.out.println(sum); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashMap; | |
import java.util.Map; | |
public class StreamMap { | |
public static void main(String args[]) { | |
Map<String, Integer> fruits = new HashMap<>(); | |
fruits.put("Banana", 7); | |
fruits.put("Apple", 2); | |
fruits.put("Kiwi", 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.stream.Stream; | |
public class StreamForEach { | |
public static void main(String args[]) { | |
System.out.println("Fruit List:"); | |
Stream.of("Banana", "Apple", "Kiwi") | |
.forEach(System.out::println); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LambdaExpression { | |
public static void main(String args[]) { | |
TouchMe touchMe = new TouchMe(System.out::println); | |
touchMe.touch(); // 1 | |
touchMe.touch(); // 2 | |
touchMe.touch(); // 3 | |
touchMe.touch(); // 4 | |
touchMe.touch(); // 5 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LambdaExpression { | |
public static void main(String args[]) { | |
TouchMe touchMe = new TouchMe(times -> System.out.println(times)); | |
touchMe.touch(); // 1 | |
touchMe.touch(); // 2 | |
touchMe.touch(); // 3 | |
touchMe.touch(); // 4 | |
touchMe.touch(); // 5 | |
} |
NewerOlder