|
Some Basic F-Script Examples
posted by Peter William Lount version 1, 20040920 12:30pm PDT Get the names of the employees: Smalltalk:
employees collect:[:anEmployee | anEmployee name]
F-Script:
employees name
Get the names of the employees whose age is greater than 30: Smalltalk:
(employees select:[: anEmployee | anEmployee age > 30]) collect:[: anEmployee | anEmployee name]
F-Script:
employees name at: employees age > 30
Get a list of employees sorted according to their salary: Smalltalk:
employees asSortedCollection:[:e1 :e2| e1 salary < e2 salary]
F-Script:
employees at: employees salary sort
Increase the salary of each employee by a specific amount: Smalltalk:
employees with:amounts do:[:anEmployee :anAmount| anEmployee raiseSalary:anAmount]
F-Script:
employees raiseSalary:amounts
Articles in the Extending Smalltalk series:
Copyright 1 9 9 9 - 2 0 1 0 b y S m a l l t a l k . o r g "! , A l l R i g h t s R e s e r v e d . |
|