[Ramda] Getter and Setter in Ramda & lens
2016-10-10 21:12
381 查看
Getter on Object:
1. prop:
2. props:
Setter ob Object:
Another way to use Lens:
1. prop:
R.prop('x', {x: 100}); //=> 100 R.prop('x', {}); //=> undefined
2. props:
R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2] R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2]
Setter ob Object:
R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
Another way to use Lens:
var xLens = R.lens(R.prop('x'), R.assoc('x')); R.view(xLens, {x: 1, y: 2}); //=> 1 R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
相关文章推荐
- getter and setter In java
- defineGetter and defineSetter in Firefox
- How to use virtual path providers to dynamically load and compile content from virtual paths in
- OO设计精要:封装,还是封装(有感于“Why getter and setter methods are evil ”by Allen Holub )
- Grid View Paging and Sorting in ASP.Net
- org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'funcSetId' in 'class java.lang.Integer'
- Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of
- Simplified and Extended Data Binding Syntax in ASP.NET 2.0 -- Cont'd
- Warning 1 Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a fu
- JavaScript Var 'Undefined' in Firefox; IE and Opera Work fine
- Export op results in error "EXP.EXE has encountered a problem and needs to
- I did an SDK update last night and it moved adb.exe. In its place it left a file called "adb_has_mov
- Property assessor (getter/setter) in JavaScript
- 啃"创建线程"一章的疑难解析: 通读Concurrent Programming in Java: Design Principles and Patterns (2)
- as3——跳出方法,getter and setter,子类实施超类的译本
- code to solve "SOCK_NONBLOCK" and "O_NONBLOCK" undefined problem in linux
- Why getter and setter methods are evil
- AndAlso & OrElse Operators in C#短路运算符
- Q & A category in Prism forums, with some answers and samples of mine.
- Confer rel="shortcut icon" and rel="icon" in markup