mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 07:33:57 +00:00
Update function names
Follow best practices (function should be snake case [do_task()], and methods should be camel case [doTask()])
This commit is contained in:
parent
cbe2e63882
commit
52cec041d0
@ -79,14 +79,14 @@ namespace LearnHackinYMinutes {
|
|||||||
|
|
||||||
// Use `arraykey` to represent either an integer or string.
|
// Use `arraykey` to represent either an integer or string.
|
||||||
$the_answer = 42;
|
$the_answer = 42;
|
||||||
$is_answer = processKey($the_answer);
|
$is_answer = process_key($the_answer);
|
||||||
|
|
||||||
// Similarily, `num` represents either an int or float.
|
// Similarily, `num` represents either an int or float.
|
||||||
$lucky_number = 7;
|
$lucky_number = 7;
|
||||||
$lucky_square = calculate_square($lucky_number);
|
$lucky_square = calculate_square($lucky_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
function processKey(arraykey $the_answer): bool {
|
function process_key(arraykey $the_answer): bool {
|
||||||
if ($the_answer is int) {
|
if ($the_answer is int) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -217,7 +217,7 @@ namespace LearnHackinYMinutes {
|
|||||||
|
|
||||||
// As another example, `__Memoize` caches the result of a function.
|
// As another example, `__Memoize` caches the result of a function.
|
||||||
<<__Memoize>>
|
<<__Memoize>>
|
||||||
function doExpensiveTask(): ?string {
|
function do_expensive_task(): ?string {
|
||||||
// return file_get_contents('http://hacklang.org');
|
// return file_get_contents('http://hacklang.org');
|
||||||
return "dynamic string with contents from hacklang.org";
|
return "dynamic string with contents from hacklang.org";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user