그래서 몇 가지 예제 F # 코드를 통해 작업, 다음과 같은 단편으로 실행 해요 :형 제약 불일치
let divRem a b =
let x = a/b
let y = a % b
(x,y)
나는 그것을 컴파일하려고, 나는 다음과 같은 얻을 오류 :
HelloWorld\Program.fs(15,14): error FS0071: Type constraint mismatch when applying the default type 'int * int' for a type inference variable. The type '(int * int)' does not support any operators named '/' Consider adding further type constraints
그러나,
에let print n = System.Console.WriteLine(n.ToString())
print (4/2)
결과 같은 일을
2
정수 나누기 연산을 함수 정의에서 사용할 수없는 이유는 무엇입니까?
편집 : 다음은 컴파일에 실패한 전체 코드 샘플입니다.
let divRem a b =
let x = a/b
let y = a % b
(x,y)
let print n = System.Console.WriteLine(n.ToString())
print (divRem (5,3))
라인 번호에 의해 추측이 기능이 사용될 때 실제 오류이다. 컴파일에 실패한 전체 F # 파일을 게시하십시오. –