Comments (8)
Are you suggesting creating categories like in Objective-C for array, dictionary, etc. types in Swift?
from dollar.
Based on some interest I'm thinking it might be worth creating another project within this repo which would shared functionality and implement extensions for different collection types.
Developer would then have a choice to import a pure functional library like Dollar or import extensions via Cent library.
from dollar.
I think what @eklipse2k8 meant is that we don't need a class to namespace the functions, because they are implicitly namespaced by the framework's module, i.e. "Dollar". So even without having the functions grouped under a class a third party app can call them like Dollar.first([1,2])
(or just first([1,2])
) but not $.first([1,2])
.
from dollar.
@nubbel exactly. These are handy functions that you could even make some of them generics, without needing to type $.
from dollar.
@eklipse2k8 and @nubbel I see what you guys mean but to avoid ambiguity and not to pollute the namespace of the class in which it is being used it would be good to have a namespace to reference these functions by. So for example calling a function as Dollar.first imply that it is the library function and not the Swift.first which can also be implemented in the future as part of language update or another first function defined in the class. The compiler sometimes complains with Ambiguous use of 'first'
as seen here if there are duplicate function names
I created a new project in the repo that creates extensions using the functional version in this branch https://github.com/ankurp/Dollar.swift/pull/59/files#diff-ca1a7525d799b7ad848ca0362a4dd934R9
So now you can import Cent if you want extension version or import Dollar if you want to import a functional version of the library. I need to add more functions and classes before I merge this.
from dollar.
I would prefer generic functions over extensions.
from dollar.
@nubbel That is why I am keeping Dollar a separate project and framework and Cent is just an extension library using the generic functions from Dollar framework to define the extensions.
from dollar.
namespace is very important, just keep use $ and dont pollute global
from dollar.
Related Issues (20)
- Latest version doesn't work with Carthage HOT 2
- Update README/docs
- Add function for swapping elements in collection HOT 1
- Tag a release for Linux support HOT 7
- Why support only 10.1 as minimum deployment target? HOT 10
- How do you use this with Cordova swift projects? HOT 1
- multi-dimensional array flatten(my wrong)
- Swift 3.1 compatibility HOT 2
- Difference with iterator HOT 2
- Implement debounce HOT 4
- Where's String#strip()? HOT 4
- Swift 4 support
- I am getting $ is not identifier issue in XCode HOT 1
- Proposal: Array's fullfill function HOT 1
- Project Warnings: Use 'compactMap' Instead Of 'flatMap' HOT 1
- Update!!!!!!!! HOT 5
- Swift 5 support HOT 1
- Distribute to test flight failed with Carthage
- Question: Why would you not want to extend built-in objects?
- Update Package.swift to Support Swift Package Manager HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dollar.