Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard extensions #120

Merged
merged 15 commits into from Apr 26, 2020
Merged

Standard extensions #120

merged 15 commits into from Apr 26, 2020

Conversation

passsy
Copy link
Owner

@passsy passsy commented Mar 1, 2020

Add the standard kotlin extensions

  • T.let(block: (T) -> R): R
  • T.also(block: (T) -> Unit): T
  • T.takeIf(predicate: (T) -> bool): T?
  • T.takeUnless(predicate: (T) -> bool): T?

and top-level functions

  • TODO() -> Always throws [NotImplementedException] stating that operation is not implemented.
  • void repeat(int times, void Function(int) action) Executes the given function [action] specified number of [times].

no run { }?

I explicitly did not add run because

  1. I'm very careful with adding top-level functions which might conflict with other packages. run is pretty common and could lead to confusion.
  2. Dart supports this construct already
// how run would work
final result = calculation() ?? run(() => 42);
final result = calculation() ?? 
  run(() { 
   return 42
  });

// in pure dart
final result = calculation() ?? (() => 42)();
final result = calculation() ?? 
  () {
    return 42;
  })();

`run((){})` is equal to `(){}()`. Since dart supports it, it doesn't have to be in this lib
@florent37
Copy link

would be useful :)

@codecov
Copy link

codecov bot commented Apr 10, 2020

Codecov Report

Merging #120 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #120   +/-   ##
=======================================
  Coverage   99.61%   99.62%           
=======================================
  Files          38       39    +1     
  Lines        2080     2112   +32     
=======================================
+ Hits         2072     2104   +32     
  Misses          8        8           
Flag Coverage Δ
#unittests 99.62% <100.00%> (+<0.01%) ⬆️
Impacted Files Coverage Δ
lib/standard.dart 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34519d7...903c4b0. Read the comment docs.

@passsy passsy merged commit 49b2ab7 into master Apr 26, 2020
@passsy passsy deleted the feature/standard branch April 26, 2020 13:31
@passsy passsy mentioned this pull request Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants