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
| def say_hello(proc_obj, name) | |
| proc_obj.call(name) | |
| end | |
| closure = Proc.new { |name| puts "hello " + name } | |
| say_hello(closure, "world") # => "hello world" |
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
| def sum_elements_multiplied_by_two(elements) | |
| elements.inject { |sum, em| sum += em * 2 } | |
| end | |
| sum_elements_multiplied_by_two([0, 10, 15, 20]) # => 90 |
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
| def get_employee(id, &block) | |
| block.call(db_employee_find(id)) | |
| end | |
| # To get an employee name with an id of 1 | |
| get_employee(1) { |emp| emp.get_name } |
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
| def get_employee(id) | |
| return db_employee_find(id) | |
| end | |
| def get_name(object) | |
| return object.get_name |
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
| def aggregate_names_of_employees | |
| all_employees.collect { |emp| empt.getName } | |
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
| package Implementer.example; | |
| import Server.src.Client; | |
| import Server.src.Marketer; | |
| import Server.src.Memo; | |
| public class AppClient extends Client { | |
| private Memo inMemo; | |
| private Memo outMemo; |
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
| As a user | |
| I have a hashmap with key '5' value '2' inserted | |
| And I add key '5' value '3' to my hashmap | |
| Then key '5' should have value '2' | |
| And key '5' should have value '3' |
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
| As a user | |
| I add key '5' value '2' to my hashmap | |
| Then my hashmap should not be empty | |
| As a user | |
| I have a hashmap with key '5' value '2' inserted | |
| And I delete '5' from my hashmap | |
| Then key '5' should not be in my hashmap | |
| As a user |
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
| (ns test.wrapper | |
| (:gen-class | |
| :name test.Speak | |
| :state name | |
| :methods [ | |
| [hello [] String] | |
| [setName [name] void] | |
| ])) | |
| (defn -setName[this name] |
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
| (ns test.wrapper | |
| (:gen-class | |
| :name test.Speak | |
| :methods [ | |
| [hello [String] String] | |
| ])) | |
| (defn -hello [this name] | |
| (str "Hello, " name)) |