Skip to content

Update prime factors to return longs#1312

Merged
ErikSchierboom merged 1 commit intoexercism:masterfrom
robkeim:prime-factors-long
Aug 22, 2019
Merged

Update prime factors to return longs#1312
ErikSchierboom merged 1 commit intoexercism:masterfrom
robkeim:prime-factors-long

Conversation

@robkeim
Copy link
Copy Markdown
Contributor

@robkeim robkeim commented Aug 21, 2019

Fixes #1309

@robkeim robkeim force-pushed the prime-factors-long branch from cb7707a to 8aa0423 Compare August 21, 2019 20:54
Copy link
Copy Markdown
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. Two small suggestions

{
testMethod.Input["value"] = (long)testMethod.Input["value"];

if (testMethod.Expected is int[])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on mobile, so that makes reviewing a bit harder. I think you can do "Expected is int[] expected", which allows you to remove the cast below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice I didn't know you could do that!


if (testMethod.Expected is int[])
{
testMethod.Expected = ((int[])testMethod.Expected).Select(l => (long)l).ToArray();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure if it works, but you could check to see if instead of the select and the lambda, you could use "Cast".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried the following:
testMethod.Expected = expected.Cast<long>();

But that gives the following error:
Unable to cast object of type 'System.Int32' to type 'System.Int64'.'

I'd expect that error in the other sense, but not here... 🤔

@robkeim robkeim force-pushed the prime-factors-long branch from 8aa0423 to 4fccf45 Compare August 21, 2019 21:21
@ErikSchierboom ErikSchierboom merged commit 8f18ac3 into exercism:master Aug 22, 2019
@ErikSchierboom
Copy link
Copy Markdown
Member

Thanks!

@robkeim robkeim deleted the prime-factors-long branch November 8, 2019 20:27
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.

Inherent flaw in PrimeFactor exercise

2 participants